
    Ngm:                        d Z ddlmZ ddlZddlmZ dZdZdZd	Z	 e
d
          Zd Zd Zd Zd Zd Z G d de          Zd Z G d de          Z G d de          Z e            Z G d de          Z G d de          Z G d de          Z G d de          Z G d d e          Z e            Zd!e_         d"e_        d# Zd$ Zd% Z d& Z! e!d'          Z"d(e"_         d)e"_        d5d*Z#d+ Z$d, Z%d- Z&d. Z' ee          Z(d/e(_         d0e(_         ee          Z)d1e)_         d2e)_         ee	          Z*d3e*_         d4e*_        dS )6z.
Python Lexical Analyser

Regular Expressions
    )absolute_importN   )Errorsiboleoleof
c                    t          |           }|                                 d}t          |          }g }||k     rt          ||                   }|dz   }|dz  }||k     rB|t          ||                   k    r)|dz  }|dz  }||k     r|t          ||                   k    )|                    |           |                    |           ||k     |S )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          O/var/www/html/ai-engine/env/lib/python3.11/site-packages/Cython/Plex/Regexps.pychars_to_rangesr      s     QINN	AIAF
a%%IaL!!		Q!eeYq\!2!222QJEFA !eeYq\!2!222 	ee a%% M    c                     t          | t          d                    }t          |t          d          dz             }||k     r)t          d          t          d          z
  }||z   ||z   fS dS )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%   4   i    
 s3xx  Es3xx!|$$Eu}}HHs3xx	519%%tr   c                     t          | t          d                    }t          |t          d          dz             }||k     r)t          d          t          d          z
  }||z   ||z   fS dS )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)   B   r&   r   c                 j      fdt          dt                     d          D             }t          | S )z
    Given a list of codes as returned by chars_to_ranges, return
    an RE which will match a character in any of the ranges.
    c                 N    g | ]!}t          |         |d z                      "S )r   )	CodeRange).0r   	code_lists     r   
<listcomp>zCodeRanges.<locals>.<listcomp>U   s0    ^^^Qy1yQ'788^^^r   r      )ranger   Alt)r.   re_lists   ` r   
CodeRangesr4   P   s<    
 _^^^%3y>>[\B]B]^^^G=r   c                     | t           cxk    r|k     rBn n?t          t          | t                     t          t          t           dz   |                    S t          | |          S )z
    CodeRange(code1, code2) is an RE which matches any character
    with a code |c| in the range |code1| <= |c| < |code2|.
    r   )nl_coder2   RawCodeRange
RawNewliner   r   s     r   r,   r,   Y   sj    
 %<w//!U335 5 	5 E5)))r   c                   T    e Zd ZdZdZdZdZd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd ZdS )REa  RE 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                 :    t          d| j        j        z            )aM  
        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_machinezRE.build_machinev   s&     ""D"&."9#: ; ; 	;r   c                     |                                 }|                    |           |                    ||           |S )z~
        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@   mrB   cr   s        r   	build_optzRE.build_opt   s@    
 KKMMa   $$Q***r   c                 "    t          | |          S N)Seqr@   others     r   __add__z
RE.__add__       4r   c                 "    t          | |          S rO   )r2   rQ   s     r   __or__z	RE.__or__   rT   r   c                 F    | j         r| j         S |                                 S rO   )strcalc_strr@   s    r   __str__z
RE.__str__   s!    8 	#8O==??"r   c                 b    t          |t                    s|                     ||d           d S d S )NzPlex.RE instance)
isinstancer;   
wrong_typer@   numvalues      r   check_rezRE.check_re   s;    %$$ 	<OOC(:;;;;;	< 	<r   c                 x    t          |          t          d          k    r|                     ||d           d S d S )N string)typer^   r_   s      r   check_stringzRE.check_string   s=    ;;$r((""OOC11111 #"r   c                     |                      ||           t          |          dk    r1t          j        d|| j        j        t          |          fz            d S )Nr   zOInvalid value for argument %d of Plex.%s.Expected a string of length 1, got: %s)rg   r   r   PlexValueErrorr>   r?   reprr_   s      r   
check_charzRE.check_char   sk    #u%%%u::??' )Q,/1H$u++TW)W X X X ?r   c                     t          |          t          j        k    r|j        j        d|j        j        d}nt          |          j        }t          j        d|| j        j        ||fz            )N.z	 instancez<Invalid type for argument %d of Plex.%s (expected %s, got %s)rf   typesInstanceTyper>   
__module__r?   r   PlexTypeError)r@   r`   ra   expectedgots        r   r^   zRE.wrong_type   s    ;;%,,,***EO,D,D,DFCC u++&C" $:'*DN,CXs=T$T U U 	Ur   )r?   rp   __qualname____doc__nullablematch_nlrX   rF   rM   rS   rV   r[   rb   rg   rk   r^    r   r   r;   r;   j   s          HH
C
; 
; 
;            # # #< < <2 2 2X X XU U U U Ur   r;   c                     t          |           dk    r.t          t          |           t          |           dz             }nt          |           }dt	          |           z  |_        |S )z;
    Char(c) is an RE which matches the character |c|.
    r   zChar(%s))r   r,   r   SpecialSymbolrj   rX   )rL   r   s     r   Charr{      sX     1vv{{3q663q66A:..q!!d1gg%FJMr   c                   8    e Zd ZdZdZdZdZdZdZd Z	d Z
d ZdS )r7   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                 l    ||f| _         t          ||          | _        t          ||          | _        d S rO   )r1   r%   r)   )r@   r   r   s      r   __init__zRawCodeRange.__init__   s7    U^
.ue<<.ue<<r   c                    |r|                      ||t                    }|                    | j        |           |rF| j        r|                    | j        |           | j        r|                    | j        |           d S d S d S rO   )rM   BOLrJ   r1   r%   r)   r@   rK   rB   rC   rD   rE   s         r   rF   zRawCodeRange.build_machine   s     	B NN1mSAAM$$TZ=== 	P# P,,T-A;OOO# P,,T-A;OOOOO		P 	PP Pr   c                 $    d| j         | j        fz  S )NzCodeRange(%d,%d)r9   rZ   s    r   rY   zRawCodeRange.calc_str   s    !TZ$<<<r   )r?   rp   rt   ru   rv   rw   r1   r%   r)   r~   rF   rY   rx   r   r   r7   r7      si         
 HHEOO= = =
P P P= = = = =r   r7   c                        e Zd ZdZdZdZd ZdS )_RawNewlinezd
    RawNewline is a low-level RE which matches a newline character.
    For internal use only.
    r   r   c                     |r|                      ||t                    }|                      ||t                    }|                    t          t          dz   f|           d S Nr   )rM   r   EOLrJ   r6   )r@   rK   rB   rC   rD   rE   r   s          r   rF   z_RawNewline.build_machine   sZ     	B NN1mSAAMNN1mS11	'7Q;/=====r   N)r?   rp   rt   ru   rv   rw   rF   rx   r   r   r   r      s9          HH> > > > >r   r   c                   *    e Zd ZdZdZdZdZd Zd ZdS )rz   zx
    SpecialSymbol(sym) is an RE which matches the special input
    symbol |sym|, which is one of BOL, EOL or EOF.
    r   Nc                     || _         d S rO   )sym)r@   r   s     r   r~   zSpecialSymbol.__init__   s    r   c                     |r,| j         t          k    r|                     ||t                    }|                    | j         |           d S rO   )r   r   rM   r   rJ   r   s         r   rF   zSpecialSymbol.build_machine  sJ      	BS NN1mSAAM$$TX{;;;;;r   )	r?   rp   rt   ru   rv   rw   r   r~   rF   rx   r   r   rz   rz      sM          HH
C  < < < < <r   rz   c                   $    e Zd ZdZd Zd Zd ZdS )rP   z]Seq(re1, re2, re3...) is an RE which matches |re1| followed by
    |re2| followed by |re3|...c                    d}t          |          D ]$\  }}|                     ||           |o|j        }%|| _        || _        t	          |          }d}|r!|dz  }||         }|j        rd}n
|j        sn|!|| _        d S )Nr   r   )	enumeraterb   rv   r3   r   rw   )r@   r3   rv   r   rerw   s         r   r~   zSeq.__init__  s    w'' 	0 	0EArMM!R   /BKHH LL 	FAB{ ;   	 !r   c                 J   | j         }t          |          dk    r|                    |           d S |}t          |          }t          |          D ]P\  }	}
|	|dz
  k     r|                                }n|}|
                    |||||           |}|
j        p|o|
j        }Qd S Nr   r   )r3   r   rI   r   rH   rF   rw   rv   )r@   rK   rB   rC   rD   rE   r3   s1r   r   r   s2s               r   rF   zSeq.build_machine!  s    ,w<<1!!+.....BGA"7++ G G2q1u99BB$B  BIv>>>KFI,E"+		G Gr   c                 b    dd                     t          t          | j                            z  S )NzSeq(%s),joinmaprX   r3   rZ   s    r   rY   zSeq.calc_str1  %    388CT\$:$:;;;;r   Nr?   rp   rt   ru   r~   rF   rY   rx   r   r   rP   rP   
  sN        " "! ! !&G G G < < < < <r   rP   c                   $    e Zd ZdZd Zd Zd ZdS )r2   zRAlt(re1, re2, re3...) is an RE which matches either |re1| or
    |re2| or |re3|...c                    || _         d}d}g }g }d}|D ]Z}|                     ||           |j        r|                    |           d}n|                    |           |j        rd}|dz  }[|| _        || _        || _        || _        d S r   )r3   rb   rv   r   rw   nullable_resnon_nullable_res)r@   r3   rv   rw   r   r   r   r   s           r   r~   zAlt.__init__9  s     		 		BMM!R   { ,##B''' ''+++{ FAA( 0  r   c                     | j         D ]}|                    |||||           | j        rA|r|                     ||t                    }| j        D ]}|                    |||d|           d S d S )Nr   )r   rF   r   rM   r   )r@   rK   rB   rC   rD   rE   r   s          r   rF   zAlt.build_machineO  s    # 	O 	OBQ{IvNNNN  	K F $q- E E+ K K  M;6JJJJ		K 	KK Kr   c                 b    dd                     t          t          | j                            z  S )NzAlt(%s)r   r   rZ   s    r   rY   zAlt.calc_strX  r   r   Nr   rx   r   r   r2   r2   5  sN         ! ! !,K K K< < < < <r   r2   c                   $    e Zd ZdZd Zd Zd ZdS )Rep1z@Rep1(re) is an RE which matches one or more repetitions of |re|.c                 p    |                      d|           || _        |j        | _        |j        | _        d S r   )rb   r   rv   rw   )r@   r   s     r   r~   zRep1.__init___  s3    ar   c                 (   |                                 }|                                 }|                    |           | j                            ||||p| j        j        |           |                    |           |                    |           d S rO   )rH   rI   r   rF   rw   )r@   rK   rB   rC   rD   rE   r   r   s           r   rF   zRep1.build_machinee  s    [[]][[]]b!!!aR)Fdg6FOOO


2


;r   c                     d| j         z  S )NzRep1(%s)r   rZ   s    r   rY   zRep1.calc_strm  s    DG##r   Nr   rx   r   r   r   r   \  sG        JJ$ $ $     $ $ $ $ $r   r   c                   ,    e Zd ZdZdZdZd Zd Zd ZdS )
SwitchCasez
    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                 R    || _         || _        |j        | _        |j        | _        d S rO   )r   rE   rv   rw   )r@   r   rE   s      r   r~   zSwitchCase.__init__z  s&    r   c                 L    | j                             ||||| j                   d S rO   )r   rF   rE   r   s         r   rF   zSwitchCase.build_machine  s3    aY"k	+ 	+ 	+ 	+ 	+r   c                 4    | j         rd}nd}|d| j        dS )NNoCaseCase())rE   r   )r@   names     r   rY   zSwitchCase.calc_str  s-    ; 	DDD44))r   )	r?   rp   rt   ru   r   rE   r~   rF   rY   rx   r   r   r   r   q  sW         
 
BF$ $ $+ + +* * * * *r   r   z8
    Empty is an RE which matches the empty string.
    Emptyc                     t          t          t          t          |                      }dt	          |           z  |_        |S )z@
    Str1(s) is an RE which matches the literal string |s|.
    Str(%s))rP   tupler   r{   rj   rX   r   r   s     r   Str1r     s5     %D!%%&FT!WW$FJMr   c                     t          |           dk    rt          | d                   S t          t          t	          t          |                      }dd                    t	          t          |                     z  |_        |S )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   r2   r   r   r   rj   rX   )strsr   s     r   Strr     sb    
 4yyA~~DG}}eCdOO,,-#dD//!:!::
r   c                 l    t          t          |                     }dt          |           z  |_        |S )zH
    Any(s) is an RE which matches any character in the string |s|.
    zAny(%s))r4   r   rj   rX   r   s     r   Anyr     s0     **++FT!WW$FJMr   c                     t          |           }|                    dt                      |                    t                     t	          |          }dt          |           z  |_        |S )zp
    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   r4   rj   rX   )r   rangesr   s      r   AnyButr     s]    
 QF
MM!fW
MM&FQ'FJMr   rd   zT
    AnyChar is an RE which matches any single character (including a newline).
    AnyCharc                    |r<t          t          |           t          |          dz             }d| d|d|_        ng }t          dt	          |           d          D ]Q}|                    t          t          | |                   t          | |dz                      dz                        Rt          | }dt          |           z  |_        |S )a  
    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   r0   z	Range(%s))r,   r   rX   r1   r   r   r2   rj   )r   r   r   r   r   s        r   Ranger     s     
 ,3r77CGGaK00')rr222.

q#b''1%% 	E 	EAMM)C1JJBq1uI0BCCDDDDf 488+
Mr   c                 D    t          | t                    }d| z  |_        |S )zI
    Opt(re) is an RE which matches either |re| or the empty string.
    zOpt(%s))r2   r   rX   r   r   s     r   Optr     s!     U^^FRFJMr   c                 R    t          t          |                     }d| z  |_        |S )zJ
    Rep(re) is an RE which matches zero or more repetitions of |re|.
    zRep(%s))r   r   rX   r   s     r   Repr     s%     b]]FRFJMr   c                 $    t          | d          S )z
    NoCase(re) is an RE which matches the same strings as RE, but treating
    upper and lower case letters as equivalent.
    r   rE   r   r   s    r   r   r     s    
 b####r   c                 $    t          | d          S )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.
    EofrO   )+ru   
__future__r   rn   rd   r   r   r   r   EOFr   r6   r   r%   r)   r4   r,   objectr;   r{   r7   r   r8   rz   rP   r2   r   r   r   rX   r   r   r   r   r   r   r   r   r   r   r   r   r   rx   r   r   <module>r      sj   
 ' & & & & &       	 
#d))  .      
* 
* 
*"EU EU EU EU EU EU EU EU^	 	 	= = = = =2 = = =>> > > > >" > > > []]
< < < < <B < < <((< (< (< (< (<" (< (< (<V$< $< $< $< $<" $< $< $<N$ $ $ $ $2 $ $ $** * * * * * * *D 	  	  
 
 
  
 
 
 &**     &    $ $ $$ $ $ d3ii  
d3ii  
d3ii  r   