
    NgN              	          d dl mZ d dlZ ej        eeeeeee           d dlZd dlZd dlmZ d dl	m
Z
 ddlmZ ddlmZ dd	lmZ d
dlmZmZmZmZmZ d
dlmZmZmZ d
dlmZ d Zd Zd ZdZ da!d Z"g dZ#e#g dz   Z$ G d de          Z%d Z& G d de          Z' G d de'          Z( G d de'          Z) G d de          Z*e
 ej+        e          d                         Z,dS )    )absolute_importN)make_lexiconlexiconprint_functionerrorwarningosplatform)	normalize)contextmanager   )Utils)Scanner)UnrecognizedInput   )r   r   hold_errorsrelease_errorsCompileError)any_string_prefixr   IDENT)r   c                  :    t           st                      a t           S N)r   r        T/var/www/html/ai-engine/env/lib/python3.11/site-packages/Cython/Compiler/Scanning.pyget_lexiconr   !   s     !..Nr   )globalnonlocaldefclassprintdelpassbreakcontinuereturnraiseimportexectryexceptfinallywhileifelifelseforinassertandornotislambdafromyieldwith)	includectypedefcdefcpdefcimportDEFIFELIFELSEc                   4    e Zd ZddZd Zd Zd Zd Zd ZdS )	CompileTimeScopeNc                 "    i | _         || _        d S r   )entriesouter)selfrI   s     r   __init__zCompileTimeScope.__init__<   s    


r   c                     || j         |<   d S r   rH   )rJ   namevalues      r   declarezCompileTimeScope.declare@   s    "Tr   c                 :    | j                             |           d S r   )rH   updaterJ   others     r   rR   zCompileTimeScope.updateC   s    E"""""r   c                     | j         |         S r   rM   rJ   rN   s     r   lookup_herezCompileTimeScope.lookup_hereF   s    |D!!r   c                     || j         v S r   rM   rV   s     r   __contains__zCompileTimeScope.__contains__I   s    t|##r   c                     	 |                      |          S # t          $ r" | j        }|r|                    |          cY S  w xY wr   )rW   KeyErrorrI   lookup)rJ   rN   rI   s      r   r\   zCompileTimeScope.lookupL   s`    	##D))) 	 	 	JE ||D)))))	s    (AAr   )	__name__
__module____qualname__rK   rP   rR   rW   rY   r\   r   r   r   rF   rF   :   ss           # # ## # #" " "$ $ $    r   rF   c                     t                      } d}t          |t          j                              D ]\  }}|                     ||           	 dd l}n# t          $ r dd l}Y nw xY wd}|D ]7}	 |                     |t          ||                     (# t          $ r Y 4w xY wddl
m} |                     d|           |                     dt          |dt          |d                               |                     dt          |dt          |d	                               |                     d
t          |d
t          |d                               t          |           }|S )N)UNAME_SYSNAMEUNAME_NODENAMEUNAME_RELEASEUNAME_VERSIONUNAME_MACHINEr   )*FalseTrueabsallanyasciibinbool	bytearraybyteschrcmpcomplexdictdivmod	enumeratefilterfloatformat	frozensethashhexintlenlistmapmaxminoctordpowrangereprreversedroundsetslicesortedstrsumtuplezip)reducer   unicoder   longr|   xranger   )rF   r   r
   unamerP   __builtin__ImportErrorbuiltinsgetattrAttributeError	functoolsr   )benvnamesrN   rO   r   r   denvs          r   initial_compile_time_envr   W   s   DbE5(."2"233 " "eT5!!!!&&&&&   
E   	LLwx667777 	 	 	D	
 !     LL6"""LLGHi59Q9QRRSSSLL678U3K3KLLMMMLL78Xwx7Q7QRRSSSD!!DKs$   A A%$A%/$B
B! B!c                   b    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 Zd Zd ZdS )SourceDescriptorz<
    A SourceDescriptor should be considered immutable.
    NFpyx c                     J r   r   rJ   s    r   __str__zSourceDescriptor.__str__   s    r   c                 t    t           j                            |          \  }}|dv r
|dd          pd| _        d S )N)z.pyxz.pxdz.pyr   r   )r	   pathsplitext
_file_type)rJ   filenamerN   exts       r   set_file_type_from_namez(SourceDescriptor.set_file_type_from_name   s>    G$$X..	c!88DSWMr   c                     | j         dv S )N)r   pxdr   r   s    r   is_cython_filezSourceDescriptor.is_cython_file   s    .00r   c                     | j         dk    S )Npyr   r   s    r   is_python_filezSourceDescriptor.is_python_file   s    $&&r   c                     | j         V|                                                     dd                              d          }|                    dd          | _         | j         S )NASCIIreplace\/)_escaped_descriptionget_descriptionencodedecoder   )rJ   esc_descs     r   get_escaped_descriptionz(SourceDescriptor.get_escaped_description   s`    $,$$&&--gyAAHHQQ  )1(8(8s(C(CD%((r   c                 F    	 | j         |j         k    S # t          $ r Y dS w xY wNF	_cmp_namer   rS   s     r   __gt__zSourceDescriptor.__gt__   8    	>EO33 	 	 	55	    
  c                 F    	 | j         |j         k     S # t          $ r Y dS w xY wr   r   rS   s     r   __lt__zSourceDescriptor.__lt__   r   r   c                 F    	 | j         |j         k    S # t          $ r Y dS w xY wr   r   rS   s     r   __le__zSourceDescriptor.__le__   s8    	>U_44 	 	 	55	r   c                     | S r   r   r   s    r   __copy__zSourceDescriptor.__copy__       r   c                     | S r   r   )rJ   memos     r   __deepcopy__zSourceDescriptor.__deepcopy__   r   r   )r]   r^   r_   __doc__r   in_utility_coder   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s          HOJI  N N N1 1 1' ' ') ) )            r   r   c                   F    e Zd ZdZddZddZd Zd Zd Zd Z	d	 Z
d
 ZdS )FileSourceDescriptora7  
    Represents a code source. A code source is a more generic abstraction
    for a "filename" (as sometimes the code doesn't come from a file).
    Instances of code sources are passed to Scanner.__init__ as the
    optional name argument and will be passed back when asking for
    the position()-tuple.
    Nc                 R   t          j        |          }|p|| _        || _        t          j                            d          t          j        z   }|                    |          r|t          |          d          n|| _
        |                     |           || _        i | _        d S )N.)r   decode_filenamepath_descriptionr   r	   r   abspathsep
startswithr}   	file_pathr   r   _lines)rJ   r   r   workdirs       r   rK   zFileSourceDescriptor.__init__   s    (22 0 <H '//#&&/4<4G4G4P4P^#g,,--00V^$$X...!r   c                    ||f}	 | j         |         }||S n# t          $ r Y nw xY wt          j        | j        ||          5 }t          |          }d d d            n# 1 swxY w Y   || j         v r|| j         |<   n
d | j         |<   |S )N)encodingerror_handling)r   r[   r   open_source_filer   r~   )rJ   r   r   keylinesfs         r   	get_lineszFileSourceDescriptor.get_lines   s     (	K$E  ! 	 	 	D	 #DMHUcddd 	hiGGE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 $+$DK  $DKs    
%%A  A$'A$c                 z    	 t           j                            | j                  S # t          $ r
 | j        cY S w xY wr   )r	   r   relpathr   
ValueErrorr   s    r   r   z$FileSourceDescriptor.get_description   sH    	)7??4#8999 	) 	) 	)((((	)s   #& ::c                     | j         }t          j        t          j                    t          j        j        z             }|                    |          r|t          |          d          S |S r   )	r   r   r   r	   getcwdr   r   r   r}   )rJ   r   cwds      r   get_error_descriptionz*FileSourceDescriptor.get_error_description   sU    }#BIKK"'+$=>>??3 	#C		?"r   c                     | j         S r   )r   r   s    r   get_filenametable_entryz,FileSourceDescriptor.get_filenametable_entry   s
    ~r   c                 L    t          |t                    o| j        |j        k    S r   )
isinstancer   r   rS   s     r   __eq__zFileSourceDescriptor.__eq__   s!    %!566Z4=EN;ZZr   c                 *    t          | j                  S r   )rz   r   r   s    r   __hash__zFileSourceDescriptor.__hash__   s    DM"""r   c                     d| j         z  S )Nz<FileSourceDescriptor:%s>)r   r   s    r   __repr__zFileSourceDescriptor.__repr__   s    *T]::r   r   NN)r]   r^   r_   r   rK   r   r   r   r   r   r   r   r   r   r   r   r      s         	 	 	 	   ,) ) )    [ [ [# # #; ; ; ; ;r   r   c                   B    e Zd ZdZd Zd
dZd ZeZd Zd Z	d Z
d	 ZdS )StringSourceDescriptorzu
    Instances of this class can be used instead of a filenames if the
    code originates from a string object.
    c                 j    || _         d |                    d          D             | _        || _        d S )Nc                     g | ]}|d z   S )
r   ).0xs     r   
<listcomp>z3StringSourceDescriptor.__init__.<locals>.<listcomp>
  s    ===q!d(===r   r   )rN   split	codelinesr   )rJ   rN   codes      r   rK   zStringSourceDescriptor.__init__  s5    	==DJJt,<,<===r   Nc                 @    s| j         S fd| j         D             S )Nc                 b    g | ]+}|                                                             ,S r   )r   r   )r   liner   r   s     r   r   z4StringSourceDescriptor.get_lines.<locals>.<listcomp>  sE     0 0 0 KK.99@@JJ 0 0 0r   )r   )rJ   r   r   s    ``r   r   z StringSourceDescriptor.get_lines  sF     	0>!0 0 0 0 0 $0 0 0 0r   c                     | j         S r   rN   r   s    r   r   z&StringSourceDescriptor.get_description  s
    yr   c                     dS )Nz<stringsource>r   r   s    r   r   z.StringSourceDescriptor.get_filenametable_entry  s    r   c                      t          |           S r   )idr   s    r   r   zStringSourceDescriptor.__hash__  s    $xxr   c                 L    t          |t                    o| j        |j        k    S r   )r   r   rN   rS   s     r   r   zStringSourceDescriptor.__eq__"  s!    %!788TTY%*=TTr   c                     d| j         z  S )Nz<StringSourceDescriptor:%s>r  r   s    r   r   zStringSourceDescriptor.__repr__%  s    ,ty88r   r   )r]   r^   r_   r   rK   r   r   r   r   r   r   r   r   r   r   r   r     s           0 0 0 0   ,       U U U9 9 9 9 9r   r   c                       e Zd Z	 	 d$dZd Zd Zd Zd Zd Zd	 Z	d
 Z
dddddZd Zd Zd Zd Zd Zd Zd Zd Zd%dZd Zd&dZd&dZd&dZd Zd Zd'd!Zd" Zd# ZdS )(PyrexScannerNTc	                 >   t          j        | t                      |||           |                                rd| _        t
          }	nd| _        t          }	d |	D             | _        d| _        |rX|j	        | _	        |j
        | _
        |j        | _        |j        | _        |j        | _        |j        r|                                  nn|| _	        |j
        | _
        t                      | _        d| _        d| _        t!          |j        dd           r$| j                            |j        j                   || _        || _        t*          | _        dg| _        d | _        d| _        d | _        |                     d           d| _        |                                  d S )	NTFc                     i | ]}||S r   r   )r   keywords     r   
<dictcomp>z)PyrexScanner.__init__.<locals>.<dictcomp>>  s    BBBg'BBBr   r   r   compile_time_envINDENTr   )r   rK   r   r   in_python_filepy_reserved_wordspyx_reserved_wordskeywordsasync_enabledcontextincluded_filesr  compile_time_evalcompile_time_exprenter_asyncr   r   optionsrR   parse_commentssource_encodingtrace_scannertraceindentation_stackindentation_charbracket_nesting_levelput_back_on_failurebeginsynext)
rJ   filer   parent_scannerscoper  r   r  initial_posr  s
             r   rK   zPyrexScanner.__init__4  s   {}}dHkJJJ""$$ 	*"&D(HH"'D)HBBBBB 	O)1DL"0"?D$2$CD!%3%ED"%3%ED"+ #  """"DL"'"6D$<$>$>D!%&D"%&D"w(:DAA O%,,W_-MNNN,."
"# $%&"#' 

8		r   c                     	 |                     d           n # t          $ r t          d|          }Y nw xY w|                     t          |           d S )Nrk   NFKC)r   UnicodeEncodeErrorr   producer   rJ   texts     r   normalize_identzPyrexScanner.normalize_ident`  sd    	+KK    ! 	+ 	+ 	+VT**DDD	+UD!!!!!s    55c                 D    | j         r|                     d|           d S d S )Ncommentline)r  r1  r2  s     r   r6  zPyrexScanner.commentlineg  s1     	.LL-----	. 	.r   c                 Z    |                      ||                    dd                     d S )N_r   )r1  r   )rJ   r3  symbols      r   strip_underscoreszPyrexScanner.strip_underscoresk  s*    VT\\#r2233333r   c                     | j         d         S )N)r#  r   s    r   current_levelzPyrexScanner.current_leveln  s    %b))r   c                 &    | xj         dz  c_         |S Nr   r%  r2  s     r   open_bracket_actionz PyrexScanner.open_bracket_actionq      ""a'""r   c                 &    | xj         dz  c_         |S r?  r@  r2  s     r   close_bracket_actionz!PyrexScanner.close_bracket_actionu  rB  r   c                 v    | j         dk    r-|                     d           |                     dd           d S d S )Nr   r  NEWLINEr   )r%  r'  r1  r2  s     r   newline_actionzPyrexScanner.newline_actiony  sD    %**JJx   LLB''''' +*r   	SQ_STRING	DQ_STRING
TSQ_STRING
TDQ_STRING)'"z'''z"""c                     |d d         t           v r|dd          }|d d         t           v |                     | j        |                    |                     d           d S )Nr   BEGIN_STRING)r   r'  string_statesr1  r2  s     r   begin_string_actionz PyrexScanner.begin_string_action  sk    2A2h+++8D 2A2h+++

4%d+,,,^$$$$$r   c                 Z    |                      d           |                     d           d S )Nr   
END_STRING)r'  r1  r2  s     r   end_string_actionzPyrexScanner.end_string_action  s)    

2\"""""r   c                 Z    |                      |           |                     d           d S )NzUnclosed string literal)rT  error_at_scanposr2  s     r   unclosed_string_actionz#PyrexScanner.unclosed_string_action  s1    t$$$788888r   c                    |                      d           |rf|d         }| j        || _        n | j        |k    r|                     d           |                    |d          dk    r|                     d           |                                 }t          |          }||k    rd S ||k    r2| j                            |           |                     dd           d S ||                                 k     rG| j        	                                 |                     dd           ||                                 k     G||                                 k    r|                     d           d S d S )Nr   r   zMixed use of tabs and spacesr  DEDENTzInconsistent indentation)
r'  r$  rV  r   r=  r}   r#  appendr1  pop)rJ   r3  cr=  	new_levels        r   indentation_actionzPyrexScanner.indentation_action  s   

2
  
	FQA$,()%% (A--))*HIII||Ar""b((%%&DEEE**,,II	%%F&&")))444LL2&&&&&d002222&**,,,Xr*** d002222
 D..0000%%&@AAAAA 10r   c                     t          | j                  dk    rG|                     dd           | j                                         t          | j                  dk    G|                     dd           d S )Nr   rY  r   EOF)r}   r#  r1  r[  r2  s     r   
eof_actionzPyrexScanner.eof_action  su    $())A--LL2&&&"&&((( $())A-- 	UBr   c                 P   	 |                                  \  }}n&# t          $ r |                     d           Y d S w xY w|t          k    r|| j        v rt|dk    r/t
          | j        j        v r| j                            dd            n?|dk    r,| j        j	        dk    r| j                            dd            n| j        |         }| j        
                    |          }| j        /| j                            |||                                 f           || _        || _        d S )NzUnrecognized characterr!   r)      )readr   rV  r   r  r   r  future_directivesr[  language_levelintern_ustringr&  rZ  positionr(  systringr!   )rJ   r(  ri  r8  r  colts          r   r)  zPyrexScanner.next  s;   	99;;LB  	 	 	!!":;;;FF	 ;;4=((x''Ndl>\,\,\M%%gt4444((T\-HA-M-MM%%fd3333x0B|228<<H#/$++R4==??,KLLL 	5 	5s    ==c                     | j         | j        f}|                                 }|                                  | j         | j        f}|                     | j         | j        |                                            |\  | _         | _        || _        |S r   )r(  ri  rh  r)  unreadlast_token_position_tuple)rJ   saved	saved_posr)  s       r   peekzPyrexScanner.peek  su    &MMOO			w%DGT]DMMOO<<<!&)2&r   c                 |    |                      | j        | j        | j                   || _        || _        || _        d S r   )rm  r(  ri  rn  )rJ   r(  ri  poss       r   put_backzPyrexScanner.put_back  s;    DGT]D,JKKK ),&&&r   c                     ||                                  }| j        dk    rt          |d           t          ||          }|r|d S )Nr  z!Possible inconsistent indentation)rh  r(  r   )rJ   messagers  fatalerrs        r   r   zPyrexScanner.error  sQ    ;--//C7h#:;;;C!!)r   c                 \    |                                  }|                     ||d           d S NT)get_current_scan_posr   )rJ   rv  rs  s      r   rV  zPyrexScanner.error_at_scanpos  s1     ''))

7C&&&&&r   c                 t    | j         |k    r|                                  d S |                     ||           d S r   )r(  r)  expectedrJ   whatrv  s      r   expectzPyrexScanner.expect  s8    7d??IIKKKKKMM$(((((r   c                     | j         t          k    r!| j        |k    r|                                  d S |                     ||           d S r   )r(  r   ri  r)  r}  r~  s      r   expect_keywordzPyrexScanner.expect_keyword  sF    7e 5 5IIKKKKKMM$(((((r   c                     |r|                      |           d S | j        t          k    r| j        }n| j        }|                      d|d|d           d S )Nz
Expected 'z
', found 'rL  )r   r(  r   ri  )rJ   r  rv  founds       r   r}  zPyrexScanner.expected  sg     	DJJww%JJJdddEEEBCCCCCr   c                 2    |                      dd           d S )Nr  z)Expected an increase in indentation levelr  r   s    r   expect_indentzPyrexScanner.expect_indent  s    HIJJJJJr   c                 2    |                      dd           d S )NrY  z(Expected a decrease in indentation levelr  r   s    r   expect_dedentzPyrexScanner.expect_dedent  s    HHIIIIIr   Expected a newlineFc                     d }|r3| j         dk    r(|                                 }|                                  | j         dk    r|                     d|           |t	          |d           d S d S )N;r`  rF  zuseless trailing semicolon)r(  rh  r)  r  r   )rJ   rv  ignore_semicolonuseless_trailing_semicolons       r   expect_newlinezPyrexScanner.expect_newline  s|    %)" 	3)-&IIKKK7eKK	7+++%1.0LMMMMM 21r   c                 h    | xj         dz  c_         | j         dk    rd| j        d<   d| j        d<   d S d S )Nr   asyncawait)r  r  r   s    r   r  zPyrexScanner.enter_async  sJ    a""%,DM'"%,DM'""" #"r   c                     | j         dk    sJ | xj         dz  c_         | j         sL| j        d= | j        d= | j        dv r5t          | j                            | j                  c| _        | _        d S d S d S )Nr   r   r  r  )r  r  )r  r  r(  r   r  rg  ri  r   s    r   
exit_asynczPyrexScanner.exit_async$  s    !A%%%%a! 	Ug&g&w,,,).0K0KDG0T0T&		U 	U -,r   )NNNNTNrz  r   )r  F)r]   r^   r_   rK   r4  r6  r:  r=  rA  rD  rG  rP  rQ  rT  rW  r^  ra  r)  rq  rt  r   rV  r  r  r}  r  r  r  r  r  r   r   r   r  r  +  s        7;bf* * * *X" " ". . .4 4 4* * *    ( ( ( 	 M% % %# # #9 9 9"B "B "BH     5 5 56  - - -   ' ' ') ) ) )) ) ) )D D D DK K KJ J J	N 	N 	N 	N- - -U U U U Ur   r  )scannerc              #     K   t                      }	 | j        }g | _        | j        | j        |                                 f}	 |V  n# t
          $ r
}Y d }~nd }~ww xY w|r;| j        r3t          | j        d d                   D ]} | j        |   | j        |  n||                    | j                   || _        ne# |r;| j        r3t          | j        d d                   D ]} | j        |   | j        |  n||                    | j                   || _        w xY w	 t          d           d S # t          d           w xY w)Nr<  T)ignore)
r   r&  r(  ri  rh  r   r   rt  extendr   )r  errorsr&  initial_stateert  s         r   tentatively_scanr  -  s      ]]F$%9&(# W%5w7G7G7I7IJ	>LLLL 	 	 	DDDD	  	H. 5$,W-H"-M$N$N 4 4(((333$G$m44$0 $**7+FGGG*=G''  	H. 5$,W-H"-M$N$N 4 4(((333$G$m44$0 $**7+FGGG*=G'===='d######d#####sC   /D7 A B? 
AB? AB? A!D7 ?A"D!!D7 7E	)-
__future__r   cythonrP   objectr	   r
   unicodedatar   
contextlibr   r   r   Plex.Scannersr   Plex.Errorsr   Errorsr   r   r   r   r   Lexiconr   r   r   Futurer   debug_scannerr!  scanner_debug_flagsscanner_dump_filer   r   r  r  rF   r   r   r   r   r  localsr  r   r   r   <module>r     s   ' & & & & &  FF$FF6+ + + + 
			  ! ! ! ! ! ! % % % % % %       # # # # # # + + + + + + M M M M M M M M M M M M M M ; ; ; ; ; ; ; ; ; ; " " " " " "  
      ' * * *      v   :% % %T: : : : :v : : :zA; A; A; A; A;+ A; A; A;H$9 $9 $9 $9 $9- $9 $9 $9R@U @U @U @U @U7 @U @U @UD w$ $   $ $ $r   