
    h13                     x    S r SSKr\R                  " \\\\S9  SSKJr  SSKJrJrJ	r	  \" 5       r
 " S S5      rg)	z3
Python Lexical Analyser

Scanning an input stream
    N)BOLEOLEOF	NOT_FOUND   )Errors)r   r   r   c                       \ rS rSrSrSS jrS rS rS rS r	\
R                  S	 5       rS
 rS\4S jrS rS rSS jrS r\S 5       rSrg)Scanner   a  
A Scanner is used to read tokens from a stream of characters
using the token set specified by a Plex.Lexicon.

Constructor:

  Scanner(lexicon, stream, name = '')

    See the docstring of the __init__ method for details.

Methods:

  See the docstrings of the individual methods for more
  information.

  read() --> (value, text)
    Reads the next lexical token from the stream.

  position() --> (name, line, col)
    Returns the position of the last token read using the
    read() method.

  begin(state_name)
    Causes scanner to change state.

  produce(value [, text])
    Causes return of a token value to the caller of the
    Scanner.

Nc                    SU l         SU l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        SU l	        SU l
        Xl        X l        X0l        / U l        SU l        U R!                  S5        SU l        SU l        SU l        [$        U l        SU l        Ub  US   US   * sU l        U l        gg)aC  
Scanner(lexicon, stream, name = '')

  |lexicon| is a Plex.Lexicon instance specifying the lexical tokens
  to be recognised.

  |stream| can be a file object or anything which implements a
  compatible read() method.

  |name| is optional, and may be the name of the file being
  scanned or any other identifying string.
r    r   )r   r   r   N   )tracebufferbuf_start_posnext_poscur_poscur_line	start_poscurrent_scanner_position_tuplelast_token_position_tupletext
state_namelexiconstreamnamequeueinitial_statebegincur_line_startr   cur_charinput_state)selfr   r   r   initial_poss        N/var/www/fran/franai/venv/lib/python3.13/site-packages/Cython/Plex/Scanners.py__init__Scanner.__init__J   s     
.8+)3&		
!

2"1<Q+a..DM4. #    c                 4   U R                   nU(       du  U R                  5       u  U l        nUc"  U R                  S5        U R	                  5         O/UR                  X R                  5      nUb  U R                  U5        U(       d  Mu  US   u  o@l        US	 U$ )z
Read the next lexical token from the stream and return a
tuple (value, text), where |value| is the value associated with
the token as specified by the Lexicon, and |text| is the actual
string read from the stream. Returns (None, '') on end of file.
Nr   )r   scan_a_tokenr   produceeofperformr   )r#   r   actionvalueresults        r%   readScanner.readr   s     

 $ 1 1 3DIv~T"
tYY7$LL' % 27q..!Hr(   c                 B    U R                   R                  SX4U45        g )Nr   )r   insert)r#   tokenr/   positions       r%   unreadScanner.unread   s    

!unh78r(   c                     U R                   $ N)r   r#   s    r%   get_current_scan_posScanner.get_current_scan_pos   s    222r(   c                    U R                   U l        U R                  U R                  U R                   U R                  -
  4U l        U R                  5       nUbu  U R                  (       a$  [        SXR                  U R                   4-  5        U R                  U R                  U R                  -
  U R                   U R                  -
   nX!4$ U R                   U R                  :X  aD  U R                  [        L a  U R                  5         U R                  b  U R                  [        L a  g[        R                   " X R"                  5      e)zv
Read the next input sequence recognised by the machine
and return (text, action). Returns ('', None) on end of
file.
z"Scanner: read: Performing %s %d:%dr   N)r   r   r   r   r    r   run_machine_inlinedr   printr   r   r!   r   	next_charr   r   UnrecognizedInputr   )r#   r.   r   s      r%   r*   Scanner.scan_a_token   s    IIt}}dllT5H5H&H/
+ ))+zz:NNDLL>: : ;;;!3!33t1113D >!||t~~-==C'NN$==(DMMS,@%**4AAr(   c           	         U R                   nU R                  nU R                  nU R                  nU R                  nU R
                  nU R                  nU R                  nU R                  n	[        U5      n
Su  ppnnnU R                  n U(       a  [        SUS   Xb[        U5      4-  5        US   nUb  UX#XEXg4u  ppnnnUnUR                  U[        5      nU[        L a  U=(       a    UR                  S5      nU(       a  U(       a  [        SUS   -  5        UnUS:X  a  UnXy-
  nUU
:  a  UU   nUS-  nOqU R                  U	-
  nU R                   R#                  S	5      nU R                  US U-   nXl        U	U-  n	Xl        [        U5      n
UU-  nU(       a  UU   nUS-  nOS
nUS:X  a	  [$        nSnOmU(       d	  [$        nSnO]UnOZUS:X  a  SnSnOOUS:X  a  US-  nU=pB[&        nSnO8US:X  a	  [(        nSnO)S
nO&U(       a  [        S5        Ub  XXUUU4u  np#npVnOSnOGM  X l        X0l        X@l        XPl        X`l        Xpl        U(       a  Ub  [        SU-  5        U$ )z+
Inlined version of run_machine for speed.
)Nr   r   r   r   r   r   r   zState %d, %d/%d:%s -->numberr.   NelsezState %di   r   
r            blockedzDoing %s)r   r   r   r    r!   r"   r   r   r   lenr   rA   reprgetr   r   r   r1   r   r   r   )r#   stater   r   r    r!   r"   r   r   r   buf_lenb_action	b_cur_pos
b_cur_lineb_cur_line_start
b_cur_charb_input_state
b_next_posr   r.   c	new_state	buf_indexdiscarddatas                            r%   r@   Scanner.run_machine_inlined   s   
 ((%)\\&*mm,0,?,?==#'#3#3&*mmkk+/+=+=%([
 $ 	aZ:}V` "ZZ.(O[4>2K K L 8_F!G~^ iZ:}^h A		!Y/II%3%))F"3	*y'::;!!#&G ( 8I 7*"9- A"&..="@#{{//7!%WX!6!=&,%0-:*"%f+!W,	 &y 1A$MH "ADy#&&'#&&'#$ A%#H"#K A%MH/77N"H"#K A%"H"#K!H )$' "j#]J@6VWH "F[ `  , & !j6)*r(   c                    U R                   nU R                  (       a  [        SSXR                  4-  5        US:X  a[  U R                  U l        U R                  5       nUS:X  a  [        U l        SU l         OU(       d  [        U l        SU l         OX l        O{US:X  a  SU l        SU l         OfUS:X  a@  U =R                  S-  sl        U R                  =U l	        U l        [        U l        SU l         O US:X  a  [        U l        SU l         OS	U l        U R                  (       a%  [        S
XR                  U R                  4-  5        g g )NzScanner: next: %s [%d] %dz                    r   rH   r   rI   rJ   rK   r   z--> [%d] %d %r)r"   r   rA   r   r   	read_charr   r!   r   r    r   r   )r#   r"   rY   s      r%   rB   Scanner.next_char  s   "&"2"2::-;0UUV!==DL ADy ##$  ##$  !A DM DAMMQM15>D$,DM DADM DDM::"k<<%OOP r(   returnc                     U R                   $ )a5  
Return a tuple (name, line, col) representing the location of
the last token read using the read() method. |name| is the
name that was provided to the Scanner constructor; |line|
is the line number in the stream (1-based); |col| is the
position within the line of the first character of the token
(0-based).
r   r;   s    r%   r6   Scanner.position:  s     ---r(   c                 "    U R                  5       $ )zH
Python accessible wrapper around position(), only for error reporting.
)r6   r;   s    r%   get_positionScanner.get_positionE  s     }}r(   c                 P    U R                   R                  U5      U l        Xl        g)z8Set the current state of the scanner to the named state.N)r   get_initial_stater   r   )r#   r   s     r%   r   Scanner.beginK  s#     LL**:6 	$r(   c                 r    Uc  U R                   nU R                  R                  X4U R                  45        g)a  
Called from an action procedure, causes |value| to be returned
as the token value from read(). If |text| is supplied, it is
returned in place of the scanned text.

produce() can be called more than once during a single call to an action
procedure, in which case the tokens are queued up and returned one
at a time by subsequent calls to read(), until the queue is empty,
whereupon scanning resumes.
N)r   r   appendr   )r#   r/   r   s      r%   r+   Scanner.produceQ  s1     <99D

E=$*M*MNOr(   c                     g)zG
Override this method if you want something to be done at
end of file.
N r;   s    r%   r,   Scanner.eof`  s    
 	r(   c                      U R                   S   $ )Nr   rd   r;   s    r%   
start_lineScanner.start_lineg  s    --a00r(   )r   r   r!   r   r    r   r   r   r"   r   r   r   r   r   r   r   r   r   r   r?   r:   )__name__
__module____qualname____firstlineno____doc__r&   r1   r7   r<   r*   cythonfinalr@   rB   tupler6   rg   r   r+   r,   propertyrs   __static_attributes__rp   r(   r%   r
   r
      sz    p&QP*93B6 \\o obQ>	.% 	.%P 1 1r(   r
   )ry   rz   declareobjectr   r   Regexpsr   r   r   r   r
   rp   r(   r%   <module>r      s=     6v6V D  " "H	X1 X1r(   