
    -PhN              	          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          Z#d Z$ G d d          Z% G d de%          Z& G d de%          Z' G d de          Z(ede(fd            Z)dS )    N)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        X/var/www/html/test/jupyter/venv/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)selfrH   s     r   __init__zCompileTimeScope.__init__;   s    


r   c                     || j         |<   d S r   rG   )rI   namevalues      r   declarezCompileTimeScope.declare?   s    "Tr   c                 :    | j                             |           d S r   )rG   updaterI   others     r   rQ   zCompileTimeScope.updateB   s    E"""""r   c                     | j         |         S r   rL   rI   rM   s     r   lookup_herezCompileTimeScope.lookup_hereE   s    |D!!r   c                     || j         v S r   rL   rU   s     r   __contains__zCompileTimeScope.__contains__H   s    t|##r   c                     	 |                      |          S # t          $ r" | j        }|r|                    |          cY S  w xY wr   )rV   KeyErrorrH   lookup)rI   rM   rH   s      r   r[   zCompileTimeScope.lookupK   s`    	##D))) 	 	 	JE ||D)))))	s    (AAr   )	__name__
__module____qualname__rJ   rO   rQ   rV   rX   r[   r   r   r   rE   rE   9   ss           # # ## # #" " "$ $ $    r   rE   c                  x   t                      } d}t          |t          j                              D ]\  }}|                     ||           dd l}d}|D ]7}	 |                     |t          ||                     (# t          $ r Y 4w xY wddlm	} |                     d|           |                     dt                     |                     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   unicodelongr{   xranger   )rE   r   r	   unamerO   builtinsgetattrAttributeError	functoolsr   r   )benvnamesrM   rN   r   r   denvs          r   initial_compile_time_envr   V   sW   DbE5(."2"233 " "eT5!!!!OOO
E   	LLwx667777 	 	 	D	
 !     LL6"""LLC   LL678U3K3KLLMMMLL78Xwx7Q7QRRSSSD!!DKs   $A>>
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   rI   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)rI   filenamerM   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                 x    | j         -|                                                     dd          | _         | j         S )N\/)_escaped_descriptionget_descriptionreplacer   s    r   get_escaped_descriptionz(SourceDescriptor.get_escaped_description   s:    $, )-(<(<(>(>(F(FtS(Q(QD%((r   c                 F    	 | j         |j         k    S # t          $ r Y dS w xY wNF	_cmp_namer   rR   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   rR   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   rR   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   )rI   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                   N    e Zd ZdZd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                    t          j        |          }|| _        |p|| _        	 t          j                            | j                  | _        n# t          $ r | j        | _        Y nw xY wt          j        	                    d          t          j
        z   }|                    |          r|t          |          d          n|| _        |                     |           || _        i | _        d S )N.)r   decode_filenamer   path_descriptionr   r   relpath_short_path_description
ValueErrorabspathsep
startswithr|   	file_pathr   r   _lines)rI   r   r   workdirs       r   rJ   zFileSourceDescriptor.__init__   s    (22  0 <H	A+-7??4;P+Q+QD(( 	A 	A 	A+/+@D(((	A '//#&&/4<4G4G4P4P^#g,,--00V^$$X...!s   )A A)(A)c                    ||f}	 | j         |         }||S n# t          $ r Y nw xY w|                     ||          5 }|                                }d d d            n# 1 swxY w Y   || j         v r|| j         |<   n
d | j         |<   |S )N)encodingerror_handling)r   rZ   get_file_object	readlines)rI   r   r   keylinesfs         r   	get_lineszFileSourceDescriptor.get_lines   s     (	K$E  ! 	 	 	D	 !!8N!SS 	"WXKKMME	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" $+$DK  $DKs    
%%A  A$'A$c                 8    t          j        | j        ||          S r   )r   open_source_filer   rI   r   r   s      r   r   z$FileSourceDescriptor.get_file_object   s    %dmX~NNNr   c                     | j         S r   )r   r   s    r   r   z$FileSourceDescriptor.get_description   s    ++r   c                     | j         }t          j        t          j                    t          j        j        z             }|                    |          r|t          |          d          S |S r   )	r   r   r   r   getcwdr   r   r   r|   )rI   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   rR   s     r   __eq__zFileSourceDescriptor.__eq__   s!    %!566Z4=EN;ZZr   c                 *    t          | j                  S r   )ry   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   rJ   r   r   r   r   r   r   r   r   r   r   r   r   r      s                ,O O O O, , ,    [ [ [# # #; ; ; ; ;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   )rM   split	codelinesr   )rI   rM   codes      r   rJ   zStringSourceDescriptor.__init__  s5    	==DJJt,<,<===r   Nc                 @    s| j         S fd| j         D             S )Nc                 b    g | ]+}|                                                             ,S r   )encodedecode)r   liner   r   s     r   r   z4StringSourceDescriptor.get_lines.<locals>.<listcomp>  sE     0 0 0 KK.99@@JJ 0 0 0r   )r   r   s    ``r   r   z StringSourceDescriptor.get_lines  sF     	0>!0 0 0 0 0 $0 0 0 0r   c                     | j         S r   rM   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   rM   rR   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   rJ   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efdZd Zd Zdef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"ej        f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   rJ   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   optionsrQ   parse_commentssource_encodingtrace_scannertraceindentation_stackindentation_charbracket_nesting_levelput_back_on_failurebeginsynext)
rI   filer   parent_scannerscoper  r!  r   initial_posr  s
             r   rJ   zPyrexScanner.__init__2  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                     |                                 st          d|          }|                     t          |           d S )NNFKC)isasciir
   producer   rI   texts     r   normalize_identzPyrexScanner.normalize_ident^  s;    ||~~ 	+VT**DUD!!!!!r   c                 D    | j         r|                     d|           d S d S )Ncommentline)r   r2  r3  s     r   r7  zPyrexScanner.commentlinec  s1     	.LL-----	. 	.r   c                 Z    |                      ||                    dd                     d S )N_r   )r2  r   )rI   r4  symbols      r   strip_underscoreszPyrexScanner.strip_underscoresg  s*    VT\\#r2233333r   c                     | j         d         S )N)r$  r   s    r   current_levelzPyrexScanner.current_levelj  s    %b))r   c                 &    | xj         dz  c_         |S Nr   r&  r3  s     r   open_bracket_actionz PyrexScanner.open_bracket_actionm      ""a'""r   c                 &    | xj         dz  c_         |S r@  rA  r3  s     r   close_bracket_actionz!PyrexScanner.close_bracket_actionq  rC  r   c                 v    | j         dk    r-|                     d           |                     dd           d S d S )Nr   r  NEWLINEr   )r&  r(  r2  r3  s     r   newline_actionzPyrexScanner.newline_actionu  sD    %**JJx   LLB''''' +*r   	SQ_STRING	DQ_STRING
TSQ_STRING
TDQ_STRING)'"z'''z"""r4  c                     |r*|d         t           v r|dd          }|r|d         t           v |                     | j        |                    |                     d           d S )Nr   r   BEGIN_STRING)r   r(  string_statesr2  r3  s     r   begin_string_actionz PyrexScanner.begin_string_action  sq     	tAw"3338D  	tAw"333

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

2\"""""r   c                 Z    |                      |           |                     d           d S )NzUnclosed string literal)rU  error_at_scanposr3  s     r   unclosed_string_actionz#PyrexScanner.unclosed_string_action  s1    t$$$788888r   c                    |                      d           |rj|d         }| j        dk    r|| _        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   r  zMixed use of tabs and spacesr  DEDENTzInconsistent indentation)
r(  r%  rW  r   r>  r|   r$  appendr2  pop)rI   r4  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+/+=+=+?+?'*4yy	%%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   rZ  r   EOF)r|   r$  r2  r\  r3  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   rW  r   r  r   r  future_directivesr\  language_levelintern_ustringr'  r[  positionr)  systringr    )rI   r)  rj  r9  r  colts          r   r*  zPyrexScanner.next  s;   	99;;LB  	 	 	!!":;;;FF	 ;;4=((w&&>T\=[+[+[M%%gt4444''DL,G1,L,L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)  rj  ri  r*  unreadlast_token_position_tuple)rI   saved	saved_posr*  s       r   peekzPyrexScanner.peek  su    &MMOO			w%DGT]DMMOO<<<!&)2&r   c                 |    |                      | j        | j        | j                   || _        || _        || _        d S r   )rn  r)  rj  ro  )rI   r)  rj  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)ri  r)  r   )rI   messagert  fatalerrs        r   r   zPyrexScanner.error  sQ    ;--//C7h#:;;;C!!)r   c                 \    |                                  }|                     ||d           d S NT)get_current_scan_posr   )rI   rw  rt  s      r   rW  zPyrexScanner.error_at_scanpos  s1     ''))

7C&&&&&r   c                 t    | j         |k    r|                                  d S |                     ||           d S r   )r)  r*  expectedrI   whatrw  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   rj  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 'rM  )r   r)  r   rj  )rI   r  rw  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 )NrZ  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 newlineFignore_semicolonc                     d }|r3| j         dk    r(|                                 }|                                  | j         dk    r|                     d|           |t	          |d           d S d S )N;ra  rG  zuseless trailing semicolon)r)  ri  r*  r  r   )rI   rw  r  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  rh  rj  r   s    r   
exit_asynczPyrexScanner.exit_async   s    !A%%%%a! 	Ug&g&w,,,).0K0KDG0T0T&		U 	U -,r   )NNNNTNr{  r   )r  F)!r\   r]   r^   rJ   r5  r7  r;  r>  rB  rE  rH  rQ  r   rR  rU  rX  r_  rb  r*  rr  ru  r   rW  r  r  r~  r  r  cythonbintr  r  r  r   r   r   r  r  )  s        7;bf* * * *X" " "
. . .4 4 4* * *    ( ( ( 	 M% % % % %# # #9 9 9"Bs "B "B "B "BH     5 5 56  - - -   ' ' ') ) ) )) ) ) )D D D DK K KJ J J	N 	NV[ 	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)  rj  ri  r   r   ru  extendr   )r  errorsr'  initial_stateeru  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	)*r  rO   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  rE   r   r   r   r   r  r  r   r   r   <module>r     s    FF$FF6+ + + + 
			  ! ! ! ! ! ! % % % % % %       # # # # # # + + + + + + M M M M M M M M M M M M M M ; ; ; ; ; ; ; ; ; ; " " " " " "  
      ' * * *         :" " "N8 8 8 8 8 8 8 8vE; E; E; E; E;+ E; E; E;P$9 $9 $9 $9 $9- $9 $9 $9R~U ~U ~U ~U ~U7 ~U ~U ~U@ $l $ $ $ $ $ $r   