Ë
    o^ëiš  ã                   óT   — d Z ddlZddlmZ ddlmZmZ ddlmZ  G d„ d«      Z	d	d„Z
y)
z	SQL Lexeré    N)Ú
TextIOBase)ÚtokensÚkeywords)Úconsumec                   óJ   — e Zd ZdZdZed„ «       Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd
d	„Zy)ÚLexerzrThe Lexer supports configurable syntax.
    To add support for additional keywords, use the `add_keywords` method.Nc                 ó~   — | j                   €& | «       | _         | j                   j                  «        | j                   S )zRReturns the lexer instance used internally
        by the sqlparse core functions.)Ú_default_intanceÚdefault_initialization)Úclss    ú?/var/www/eb/venv/lib/python3.12/site-packages/sqlparse/lexer.pyÚget_default_instancezLexer.get_default_instance.   s8   € ð ×ÑÐ'Ù#&£5ˆCÔ Ø× Ñ ×7Ñ7Ô9Ø×#Ñ#Ð#ó    c                 óÖ  — | j                  «        | j                  t        j                  «       | j	                  t        j
                  «       | j	                  t        j                  «       | j	                  t        j                  «       | j	                  t        j                  «       | j	                  t        j                  «       | j	                  t        j                  «       y)zlInitialize the lexer with default dictionaries.
        Useful if you need to revert custom syntax settings.N)ÚclearÚset_SQL_REGEXr   Ú	SQL_REGEXÚadd_keywordsÚKEYWORDS_COMMONÚKEYWORDS_ORACLEÚKEYWORDS_PLPGSQLÚKEYWORDS_HQLÚKEYWORDS_MSACCESSÚKEYWORDS©Úselfs    r   r   zLexer.default_initialization7   s™   € ð 	�
‰
ŒØ×Ñœ8×-Ñ-Ô.Ø×Ñœ(×2Ñ2Ô3Ø×Ñœ(×2Ñ2Ô3Ø×Ñœ(×3Ñ3Ô4Ø×Ñœ(×/Ñ/Ô0Ø×Ñœ(×4Ñ4Ô5Ø×Ñœ(×+Ñ+Õ,r   c                 ó    — g | _         g | _        y)zãClear all syntax configurations.
        Useful if you want to load a reduced set of syntax configurations.
        After this call, regexps and keyword dictionaries need to be loaded
        to make the lexer functional again.N)Ú
_SQL_REGEXÚ	_keywordsr   s    r   r   zLexer.clearC   s   € ð
 ˆŒØˆ�r   c                 óÆ   — t         j                  t         j                  z  }|D ��cg c]'  \  }}t        j                  ||«      j                  |f‘Œ) c}}| _        yc c}}w )z.Set the list of regex that will parse the SQL.N)ÚreÚ
IGNORECASEÚUNICODEÚcompileÚmatchr   )r   r   ÚFLAGSÚrxÚtts        r   r   zLexer.set_SQL_REGEXK   sO   € ä—‘¤§
¡
Ñ*ˆð $÷
á��Bô �Z‰Z˜˜EÓ"×(Ñ(¨"Ò-ó
ˆ�ùó 
s   §,Ac                 ó:   — | j                   j                  |«       y)zhAdd keyword dictionaries. Keywords are looked up in the same order
        that dictionaries were added.N)r   Úappend)r   r   s     r   r   zLexer.add_keywordsS   s   € ð 	�‰×Ñ˜hÕ'r   c                 ó‚   — |j                  «       }| j                  D ]  }||v sŒ||   |fc S  t        j                  |fS )z¨Checks for a keyword.

        If the given value is in one of the KEYWORDS_* dictionary
        it's considered a keyword. Otherwise, tokens.Name is returned.
        )Úupperr   r   ÚName)r   ÚvalueÚvalÚkwdicts       r   Ú
is_keywordzLexer.is_keywordX   sI   € ð �k‰k‹mˆØ—n‘nò 	&ˆFØ�fŠ}Ø˜c‘{ EÐ)Ò)ð	&ô —;‘; Ð%Ð%r   c              #   óú  K  — t        |t        «      r|j                  «       }t        |t        «      rnZt        |t        «      r'|r|j                  |«      }n6	 |j                  d«      }n#t        dj                  t        |«      «      «      ‚t        |«      }|D ]¼  \  }}| j                  D ]”  \  }} |||«      }|sŒt        |t        j                  «      r||j                  «       f–— n3|t        j                   u r!| j#                  |j                  «       «      –— t%        ||j'                  «       |z
  dz
  «        Œ¨ t        j(                  |f–— Œ¾ y# t        $ r |j                  d«      }Y Œéw xY w­w)a³  
        Return an iterable of (tokentype, value) pairs generated from
        `text`. If `unfiltered` is set to `True`, the filtering mechanism
        is bypassed even if filters are defined.

        Also preprocess the text, i.e. expand tabs and strip it if
        wanted and applies registered filters.

        Split ``text`` into (tokentype, text) pairs.

        ``stack`` is the initial stack (default: ``['root']``)
        zutf-8zunicode-escapez+Expected text or file-like object, got {!r}é   N)Ú
isinstancer   ÚreadÚstrÚbytesÚdecodeÚUnicodeDecodeErrorÚ	TypeErrorÚformatÚtypeÚ	enumerater   r   Ú
_TokenTypeÚgroupr   ÚPROCESS_AS_KEYWORDr1   r   ÚendÚError)	r   ÚtextÚencodingÚiterableÚposÚcharÚrexmatchÚactionÚms	            r   Ú
get_tokenszLexer.get_tokense   sP  è ø€ ô �dœJÔ'Ø—9‘9“;ˆDä�dœCÔ ØÜ˜œeÔ$ÙØ—{‘{ 8Ó,‘ð9ØŸ;™; wÓ/‘Dô ÐIß"™F¤4¨£:Ó.ó0ð 0ô ˜T“?ˆØ!ò 	)‰IˆC�Ø$(§O¡Oò )Ñ �˜&Ù˜T 3Ó'�áØÜ ¬×(9Ñ(9Ô:Ø  !§'¡'£)Ð+Ó+Øœx×:Ñ:Ñ:ØŸ/™/¨!¯'©'«)Ó4Ò4ä˜ !§%¡%£'¨C¡-°!Ñ"3Ô4Ùð)ô —l‘l DÐ(Ó(ñ	)øô *ò 9ØŸ;™;Ð'7Ó8’Dð9üs+   ‚AE;ÁE Á*C1E;ÅE8Å5E;Å7E8Å8E;©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   Úclassmethodr   r   r   r   r   r1   rK   © r   r   r   r      sB   „ ñNð Ðð( ñ$ó ð$ò
-òò
ò(ò
&ô-)r   r   c                 óJ   — t         j                  «       j                  | |«      S )z�Tokenize sql.

    Tokenize *sql* using the :class:`Lexer` and return a 2-tuple stream
    of ``(token type, value)`` items.
    )r   r   rK   )ÚsqlrD   s     r   ÚtokenizerU   •   s    € ô ×%Ñ%Ó'×2Ñ2°3¸ÓAÐAr   rL   )rP   r!   Úior   Úsqlparser   r   Úsqlparse.utilsr   r   rU   rR   r   r   ú<module>rY      s+   ðñ Û 	õ ç %Ý "÷|)ñ |)ô~Br   