
    %hg                     b    S r SSKrSSKJr  SSKJr  SSKJrJr  SSK	J
r
   " S S5      rS
S	 jrg)z	SQL Lexer    N)Lock)
TextIOBase)tokenskeywords)consumec                   b    \ rS rSrSrSr\" 5       r\S 5       r	S r
S rS rS rS	 rSS
 jrSrg)Lexer   znThe Lexer supports configurable syntax.
To add support for additional keywords, use the `add_keywords` method.Nc                     U R                      U R                  c&  U " 5       U l        U R                  R                  5         SSS5        U R                  $ ! , (       d  f       U R                  $ = f)zJReturns the lexer instance used internally
by the sqlparse core functions.N)_lock_default_instancedefault_initialization)clss    @/var/www/html/env/lib/python3.13/site-packages/sqlparse/lexer.pyget_default_instanceLexer.get_default_instance0   s\     YY$$,(+%%%<<>  $$$	 Y $$$s   4A
A.c                    U R                  5         U R                  [        R                  5        U R	                  [        R
                  5        U R	                  [        R                  5        U R	                  [        R                  5        U R	                  [        R                  5        U R	                  [        R                  5        U R	                  [        R                  5        U R	                  [        R                  5        U R	                  [        R                  5        U R	                  [        R                  5        g)zdInitialize 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_MYSQLKEYWORDS_PLPGSQLKEYWORDS_HQLKEYWORDS_MSACCESSKEYWORDS_SNOWFLAKEKEYWORDS_BIGQUERYKEYWORDSselfs    r   r   Lexer.default_initialization:   s     	

8--.(223(223(112(334(//0(445(556(445(++,    c                      / U l         / U l        g)zClear 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   Lexer.clearI   s    
 r$   c                     [         R                  [         R                  -  nU VVs/ s H'  u  p4[         R                  " X25      R                  U4PM)     snnU l        gs  snnf )z.Set the list of regex that will parse the SQL.N)re
IGNORECASEUNICODEcompilematchr'   )r"   r   FLAGSrxtts        r   r   Lexer.set_SQL_REGEXQ   sP    

* $
# ZZ"(("-#
 
s   .Ac                 :    U R                   R                  U5        g)z`Add keyword dictionaries. Keywords are looked up in the same order
that dictionaries were added.N)r(   append)r"   r   s     r   r   Lexer.add_keywordsY   s     	h'r$   c                     UR                  5       nU R                   H  nX#;   d  M
  X2   U4s  $    [        R                  U4$ )zChecks 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_keywordLexer.is_keyword^   s@     kkmnnF}{E)) % ;;%%r$   c              #   :  #    [        U[        5      (       a  UR                  5       n[        U[        5      (       a  Od[        U[        5      (       a,  U(       a  UR                  U5      nO6 UR                  S5      nO#[        SR                  [        U5      5      5      e[        U5      nU H  u  pEU R                   H  u  pgU" X5      nU(       d  M  [        U[        R                  5      (       a  XxR                  5       4v   O4U[        R                   L a!  U R#                  UR                  5       5      v   [%        X8R'                  5       U-
  S-
  5          M     [        R(                  U4v   M     g! [         a    UR                  S5      n Nf = f7f)as  
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_KEYWORDr=   r   endError)	r"   textencodingiterableposcharrexmatchactionms	            r   
get_tokensLexer.get_tokensk   sG     dJ''99;DdC  e$${{8,9;;w/D I"F4:.0 0 T?!IC$(OO T'(9(9:: '')++x::://!'')44%%'C-!"34 %4 llD(( " * 9;;'78D9s+   A*F-E: >C<F:FFFFr&   N)__name__
__module____qualname____firstlineno____doc__r   r   r   classmethodr   r   r   r   r   r=   rX   __static_attributes__ r$   r   r	   r	      sI    N FE( % %-
(
&-)r$   r	   c                 H    [         R                  5       R                  X5      $ )zuTokenize sql.

Tokenize *sql* using the :class:`Lexer` and return a 2-tuple stream
of ``(token type, value)`` items.
)r	   r   rX   )sqlrQ   s     r   tokenizere      s     %%'223AAr$   rZ   )r_   r+   	threadingr   ior   sqlparser   r   sqlparse.utilsr   r	   re   rb   r$   r   <module>rj      s.     	   % "A) A)HBr$   