
    h=:                     0   S r SSKrSSKJr  SrSrSrSr\" S	5      r	S
 r
S rS rS rS r " S S5      rS r " S S\5      r " S S\5      r\" 5       r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r\" 5       rS \l         S!\l        S" rS# rS$ rS% r\" S&5      rS'\l         S(\l        S4S) jr S* r!S+ r"S, r#S- r$\" \5      r%S.\%l         S/\%l        \" \5      r&S0\&l         S1\&l        \" \5      r'S2\'l         S3\'l        g)5z.
Python Lexical Analyser

Regular Expressions
    N   )Errorsiboleoleof
c                 T   [        U 5      nUR                  5         Sn[        U5      n/ nX#:  ax  [        X   5      nUS-   nUS-  nX#:  a3  U[        X   5      :  a"  US-  nUS-  nX#:  a  U[        X   5      :  a  M"  UR	                  U5        UR	                  U5        X#:  a  Mx  U$ )z
Return a list of character codes consisting of pairs
[code1a, code1b, code2a, code2b,...] which cover all
the characters in |s|.
r   r   )listsortlenordappend)s	char_listinresultcode1code2s          M/var/www/fran/franai/venv/lib/python3.13/site-packages/Cython/Plex/Regexps.pychars_to_rangesr      s     QINN	AIAF
%IL!		QeY\!22QJEFA eY\!22 	ee % M    c                     [        U [        S5      5      n[        U[        S5      S-   5      nX#:  a  [        S5      [        S5      -
  nX$-   X4-   4$ g)z~
If the range of characters from code1 to code2-1 includes any
lower case letters, return the corresponding upper case range.
azr   ANmaxr   minr   r   code3code4ds        r   uppercase_ranger$   3   Q    
 s3x Es3x!|$E}Hs3x	59%%r   c                     [        U [        S5      5      n[        U[        S5      S-   5      nX#:  a  [        S5      [        S5      -
  nX$-   X4-   4$ g)z~
If the range of characters from code1 to code2-1 includes any
upper case letters, return the corresponding lower case range.
r   Zr   r   Nr   r    s        r   lowercase_ranger(   A   r%   r   c           	          [        S[        U 5      S5       Vs/ s H  n[        X   XS-      5      PM     nn[        U6 $ s  snf )zw
Given a list of codes as returned by chars_to_ranges, return
an RE which will match a character in any of the ranges.
r      r   )ranger   	CodeRangeAlt)	code_listr   re_lists      r   
CodeRangesr0   O   sJ    
 CH3y>[\B]^B]QyyQ'78B]G^= _s   A c                     U [         s=::  a  U:  a3  O  O0[        [        U [         5      [        [        [         S-   U5      5      $ [        X5      $ )zu
CodeRange(code1, code2) is an RE which matches any character
with a code |c| in the range |code1| <= |c| < |code2|.
r   )nl_coder-   RawCodeRange
RawNewliner   r   s     r   r,   r,   X   sE    
 %<w/!U35 	5 E))r   c                   Z    \ rS rSrSrSrSrSrS rS r	S r
S rS	 rS
 rS rS rS rSrg)REi   zRE is the base class for regular expression constructors.
The following operators are defined on REs:

     re1 + re2         is an RE which matches |re1| followed by |re2|
     re1 | re2         is an RE which matches either |re1| or |re2|
r   Nc                 F    [        SU R                  R                  -  5      e)a  
This method should add states to |machine| to implement this
RE, starting at |initial_state| and ending at |final_state|.
If |match_bol| is true, the RE must be able to match at the
beginning of a line. If nocase is true, upper and lower case
letters should be treated as equivalent.
z %s.build_machine not implemented)NotImplementedError	__class____name__)selfmachineinitial_statefinal_state	match_bolnocases         r   build_machineRE.build_machineu   s&     ""D"&.."9"9#: ; 	;r   c                 j    UR                  5       nUR                  U5        UR                  X45        U$ )zf
Given a state |s| of machine |m|, return a new state
reachable from |s| on character |c| or epsilon.
)	new_statelink_toadd_transition)r=   mr?   cr   s        r   	build_optRE.build_opt   s0    
 KKMa $$Q*r   c                     [        X5      $ N)Seqr=   others     r   __add__
RE.__add__       4r   c                     [        X5      $ rN   )r-   rP   s     r   __or__	RE.__or__   rT   r   c                 \    U R                   (       a  U R                   $ U R                  5       $ rN   )strcalc_strr=   s    r   __str__
RE.__str__   s    8888O==?"r   c                 T    [        U[        5      (       d  U R                  XS5        g g )NzPlex.RE instance)
isinstancer7   
wrong_typer=   numvalues      r   check_reRE.check_re   s#    %$$OOC(:; %r   c                 N    [        U5      [        La  U R                  XS5        g g )Nstring)typerY   r`   ra   s      r   check_stringRE.check_string   s!    ;c!OOC1 "r   c                     U R                  X5        [        U5      S:w  a8  [        R                  " SXR                  R
                  [        U5      4-  5      eg )Nr   zOInvalid value for argument %d of Plex.%s.Expected a string of length 1, got: %s)ri   r   r   PlexValueErrorr;   r<   reprra   s      r   
check_charRE.check_char   s[    #%u:?'' )Q,/1H1H$u+TW)W X X r   c                 *   [        U5      [        R                  :X  a3  UR                  R                  < SUR                  R
                  < S3nO[        U5      R
                  n[        R                  " SXR                  R
                  X44-  5      e)N.z	 instancez<Invalid type for argument %d of Plex.%s (expected %s, got %s)rh   typesInstanceTyper;   
__module__r<   r   PlexTypeError)r=   rb   rc   expectedgots        r   r`   RE.wrong_type   s{    ;%,,,**EOO,D,DFC u+&&C"" $:'*NN,C,CX=T$T U 	Ur    )r<   rt   __qualname____firstlineno____doc__nullablematch_nlrY   rC   rK   rR   rV   r\   rd   ri   rn   r`   __static_attributes__ry   r   r   r7   r7   i   sG     HH
C
;  #<2XUr   r7   c                     [        U 5      S:X  a"  [        [        U 5      [        U 5      S-   5      nO[        U 5      nS[	        U 5      -  Ul        U$ )z3
Char(c) is an RE which matches the character |c|.
r   zChar(%s))r   r,   r   SpecialSymbolrm   rY   )rJ   r   s     r   Charr      sF     1v{3q63q6A:.q!d1g%FJMr   c                   >    \ rS rSrSrSrSrSrSrSr	S r
S rS rSrg)	r3      z
RawCodeRange(code1, code2) is a low-level RE which matches any character
with a code |c| in the range |code1| <= |c| < |code2|, where the range
does not include newline. For internal use only.
r   Nc                 T    X4U l         [        X5      U l        [        X5      U l        g rN   )r+   r$   r(   )r=   r   r   s      r   __init__RawCodeRange.__init__   s%    ^
.u<.u<r   c                 <   U(       a  U R                  X[        5      nUR                  U R                  U5        U(       a\  U R                  (       a  UR                  U R                  U5        U R
                  (       a  UR                  U R
                  U5        g g g rN   )rK   BOLrH   r+   r$   r(   r=   rI   r?   r@   rA   rB   s         r   rC   RawCodeRange.build_machine   st     NN1SAM$$TZZ=##,,T-A-A;O##,,T-A-A;O $ r   c                 8    SU R                   U R                  4-  $ )NzCodeRange(%d,%d)r5   r[   s    r   rZ   RawCodeRange.calc_str   s    !TZZ$<<<r   )r(   r+   r$   )r<   rt   rz   r{   r|   r}   r~   r+   r$   r(   r   rC   rZ   r   ry   r   r   r3   r3      s2    
 HHEOO=
P=r   r3   c                   &    \ rS rSrSrSrSrS rSrg)_RawNewline   zX
RawNewline is a low-level RE which matches a newline character.
For internal use only.
r   r   c                     U(       a  U R                  X[        5      nU R                  X[        5      nUR                  [        [        S-   4U5        g Nr   )rK   r   EOLrH   r2   )r=   rI   r?   r@   rA   rB   r   s          r   rC   _RawNewline.build_machine   s>     NN1SAMNN1S1	'7Q;/=r   ry   N)	r<   rt   rz   r{   r|   r}   r~   rC   r   ry   r   r   r   r      s     HH>r   r   c                   0    \ rS rSrSrSrSrSrS rS r	Sr
g)r      zl
SpecialSymbol(sym) is an RE which matches the special input
symbol |sym|, which is one of BOL, EOL or EOF.
r   Nc                     Xl         g rN   sym)r=   r   s     r   r   SpecialSymbol.__init__   s    r   c                     U(       a*  U R                   [        :X  a  U R                  X[        5      nUR	                  U R                   U5        g rN   )r   r   rK   r   rH   r   s         r   rC   SpecialSymbol.build_machine  s5     S NN1SAM$$TXX{;r   r   )r<   rt   rz   r{   r|   r}   r~   r   r   rC   r   ry   r   r   r   r      s"     HH
C<r   r   c                   *    \ rS rSrSrS rS rS rSrg)rO   i	  zYSeq(re1, re2, re3...) is an RE which matches |re1| followed by
|re2| followed by |re3|...c                 8   Sn[        U5       H+  u  p4U R                  X45        U=(       a    UR                  nM-     Xl        X l        [	        U5      nSnU(       a8  US-  nX   nUR
                  (       a  SnOUR                  (       d  O	U(       a  M8  XPl        g )Nr   r   )	enumeraterd   r}   r/   r   r~   )r=   r/   r}   r   rer~   s         r   r   Seq.__init__  s    w'EAMM! /BKKH (  LFAB{{;; a !r   c                 P   U R                   n[        U5      S:X  a  UR                  U5        g Un[        U5      n[        U5       H]  u  pXS-
  :  a  UR	                  5       nOUnU
R                  XXU5        UnU
R                  =(       d    U=(       a    U
R                  nM_     g Nr   r   )r/   r   rG   r   rF   rC   r~   r}   )r=   rI   r?   r@   rA   rB   r/   s1r   r   r   s2s               r   rC   Seq.build_machine   s    ,,w<1!!+.BGA"7+1u9B$B  v>KKFI,E"++	 ,r   c                 Z    SSR                  [        [        U R                  5      5      -  $ )NzSeq(%s),joinmaprY   r/   r[   s    r   rZ   Seq.calc_str0  !    388CT\\$:;;;r   )r~   r}   r/   N	r<   rt   rz   r{   r|   r   rC   rZ   r   ry   r   r   rO   rO   	  s    "!&G <r   rO   c                   *    \ rS rSrSrS rS rS rSrg)r-   i4  zNAlt(re1, re2, re3...) is an RE which matches either |re1| or
|re2| or |re3|...c                 $   Xl         SnSn/ n/ nSnU Hb  nU R                  Xg5        UR                  (       a  UR                  U5        SnOUR                  U5        UR                  (       a  SnUS-  nMd     X@l        XPl        X l        X0l        g r   )r/   rd   r}   r   r~   nullable_resnon_nullable_res)r=   r/   r}   r~   r   r   r   r   s           r   r   Alt.__init__8  s    BMM! {{##B' ''+{{FA  ) 0  r   c                     U R                    H  nUR                  XX4U5        M     U R                  (       aE  U(       a  U R                  X[        5      nU R                   H  nUR                  XUSU5        M     g g )Nr   )r   rC   r   rK   r   )r=   rI   r?   r@   rA   rB   r   s          r   rC   Alt.build_machineN  si    ##BQ{vN $   $q E++  ;6J , !r   c                 Z    SSR                  [        [        U R                  5      5      -  $ )NzAlt(%s)r   r   r[   s    r   rZ   Alt.calc_strW  r   r   )r~   r   r}   r   r/   Nr   ry   r   r   r-   r-   4  s    !,K<r   r-   c                   *    \ rS rSrSrS rS rS rSrg)Rep1i[  z@Rep1(re) is an RE which matches one or more repetitions of |re|.c                 x    U R                  SU5        Xl        UR                  U l        UR                  U l        g r   )rd   r   r}   r~   )r=   r   s     r   r   Rep1.__init__^  s+    ar   c                    UR                  5       nUR                  5       nUR                  U5        U R                  R                  XXt=(       d    U R                  R                  U5        UR                  U5        UR                  U5        g rN   )rF   rG   r   rC   r~   )r=   rI   r?   r@   rA   rB   r   r   s           r   rC   Rep1.build_machined  sb    [[][[]b!aR)Fdgg6F6FO


2


;r   c                      SU R                   -  $ )NzRep1(%s)r   r[   s    r   rZ   Rep1.calc_strl  s    DGG##r   )r~   r}   r   Nr   ry   r   r   r   r   [  s    J$ $r   r   c                   2    \ rS rSrSrSrSrS rS rS r	Sr
g)
SwitchCaseip  z
SwitchCase(re, nocase) is an RE which matches the same strings as RE,
but treating upper and lower case letters according to |nocase|. If
|nocase| is true, case is ignored, otherwise it is not.
Nc                 `    Xl         X l        UR                  U l        UR                  U l        g rN   )r   rB   r}   r~   )r=   r   rB   s      r   r   SwitchCase.__init__y  s"    r   c                 R    U R                   R                  XX4U R                  5        g rN   )r   rC   rB   r   s         r   rC   SwitchCase.build_machine  s    a"kk	+r   c                 V    U R                   (       a  SnOSnU< SU R                  < S3$ )NNoCaseCase())rB   r   )r=   names     r   rZ   SwitchCase.calc_str  s"    ;;DD))r   )r~   rB   r}   r   )r<   rt   rz   r{   r|   r   rB   r   rC   rZ   r   ry   r   r   r   r   p  s"    
 
BF$+*r   r   z8
    Empty is an RE which matches the empty string.
    Emptyc                 j    [        [        [        [        U 5      5      6 nS[	        U 5      -  Ul        U$ )z8
Str1(s) is an RE which matches the literal string |s|.
Str(%s))rO   tupler   r   rm   rY   r   r   s     r   Str1r     s.     %D!%&FT!W$FJMr   c                      [        U 5      S:X  a  [        U S   5      $ [        [        [	        [        U 5      5      6 nSSR                  [	        [        U 5      5      -  Ul        U$ )z
Str(s) is an RE which matches the literal string |s|.
Str(s1, s2, s3, ...) is an RE which matches any of |s1| or |s2| or |s3|...
r   r   r   r   )r   r   r-   r   r   r   rm   rY   )strsr   s     r   Strr     sR    
 4yA~DG}eCdO,-#dD/!::
r   c                 T    [        [        U 5      5      nS[        U 5      -  Ul        U$ )z@
Any(s) is an RE which matches any character in the string |s|.
zAny(%s))r0   r   rm   rY   r   s     r   Anyr     s(     *+FT!W$FJMr   c                     [        U 5      nUR                  S[        * 5        UR                  [        5        [	        U5      nS[        U 5      -  Ul        U$ )zd
AnyBut(s) is an RE which matches any character (including
newline) which is not in the string |s|.
r   z
AnyBut(%s))r   insertmaxintr   r0   rm   rY   )r   rangesr   s      r   AnyButr     sI    
 QF
MM!fW
MM&FQ'FJMr    zT
    AnyChar is an RE which matches any single character (including a newline).
    AnyCharc                 \   U(       a3  [        [        U 5      [        U5      S-   5      nSU < SU< S3Ul        U$ / n[        S[	        U 5      S5       H:  nUR                  [        [        X   5      [        XS-      5      S-   5      5        M<     [        U6 nS[        U 5      -  Ul        U$ )z
Range(c1, c2) is an RE which matches any single character in the range
|c1| to |c2| inclusive.
Range(s) where |s| is a string of even length is an RE which matches
any single character in the ranges |s[0]| to |s[1]|, |s[2]| to |s[3]|,...
r   zRange(r   r   r   r*   z	Range(%s))r,   r   rY   r+   r   r   r-   rm   )r   r   r   r   r   s        r   Ranger     s     
3r7CGaK0')2.
 M q#b'1%AMM)CJB1uI0BCD &f 48+
Mr   c                 :    [        U [        5      nSU -  Ul        U$ )zA
Opt(re) is an RE which matches either |re| or the empty string.
zOpt(%s))r-   r   rY   r   r   s     r   Optr     s     U^FRFJMr   c                 B    [        [        U 5      5      nSU -  Ul        U$ )zB
Rep(re) is an RE which matches zero or more repetitions of |re|.
zRep(%s))r   r   rY   r   s     r   Repr     s!     b]FRFJMr   c                     [        U SS9$ )zt
NoCase(re) is an RE which matches the same strings as RE, but treating
upper and lower case letters as equivalent.
r   rB   r   r   s    r   r   r     s    
 b##r   c                     [        U SS9$ )z
Case(re) is an RE which matches the same strings as RE, but treating
upper and lower case letters as distinct, i.e. it cancels the effect
of any enclosing NoCase().
r   r   r   r   s    r   r   r     s     b##r   z=
    Bol is an RE which matches the beginning of a line.
    Bolz7
    Eol is an RE which matches the end of a line.
    Eolz9
    Eof is an RE which matches the end of the file.
    EofrN   )(r|   rr   r   r   r   r   r   EOFr   r2   r   r$   r(   r0   r,   r7   r   r3   r   r4   r   rO   r-   r   r   r   rY   r   r   r   r   r   r   r   r   r   r   r   r   r   ry   r   r   <module>r      s    	 
d).
*"EU EU^	=2 =>>" > ]
<B <((<" (<V$<" $<N$2 $** *D 	  	

 *  &$$ 3i  
3i  
3i  r   