Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/Cython/Plex/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/Cython/Plex/__pycache__/Scanners.cpython-37.pyc

B

Z��Z�/�@s`ddlmZddlZejeeeed�ddlmZddlmZm	Z	m
Z
e�ZGdd�de�ZdS)	�)�absolute_importN)�BOL�EOL�EOF�	NOT_FOUND�)�Errors)rrrc@sdeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zddd�Zdd�Z
dS)�Scannera�
    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.

    �NcCs�d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
||_||_||_
g|_d|_|�d�d|_d|_d|_t|_d|_|dk	r�|d|d|_|_dS)a�
        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.
        rr
rN�)�trace�buffer�
buf_start_pos�next_pos�cur_pos�cur_line�	start_pos�
start_line�	start_col�text�
state_name�lexicon�stream�name�queue�
initial_state�begin�cur_line_startr�cur_char�input_state)�selfrrrZinitial_pos�r!�G/opt/alt/python37/lib64/python3.7/site-packages/Cython/Plex/Scanners.py�__init__Hs0

zScanner.__init__cCsl|j}xR|sX|��\|_}|dkr6|�d�|��q|�||j�}|dk	r|�|�qW|d}|d=|S)a"
        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�eofZperform)r r�action�value�resultr!r!r"�readps

zScanner.readcCs�|j|_|j|_|j|j|_|��}|dk	rp|jrJtd||j|jf�|j	|j|j
|j|j
�}||fS|j|jkr�|jtkr�|�
�|jdks�|jtkr�dSt�||j��dS)z�
        Read the next input sequence recognised by the machine
        and return (text, action). Returns ('', None) on end of
        file.
        Nz"Scanner: read: Performing %s %d:%d)r
N)rrrrrr�run_machine_inlinedr�printr
rrr�	next_charrrZUnrecognizedInputr)r r'rr!r!r"r$�s$

zScanner.scan_a_tokencCs�|j}|j}|j}|j}|j}|j}|j}|j}|j}	t	|�}
d\}}}
}}}}|j
}�x�|rztd|d||t|�f�|d}|dk	r�|||||||f\}}}
}}}}|}|�
|t�}|tkr�|o�|�
d�}|�r|r�td|d�|}|dk�r�|}||	}||
k�r ||}|d7}nh|j|	}|j�d	�}|j|d�|}||_|	|7}	|	|_t	|�}
||8}|�r�||}|d7}nd
}|dk�r�t}d}n|�s�t}d
}n|}nP|dk�r�d}d}n<|dk�r�|d7}|}}t}d}n|d
k�r�t}d}nd
}qZ|�rtd�|dk	�r>|||
||||f\}}}}}}}nd}PqZW||_||_||_||_||_||_|�r�|dk	�r�td|�|S)z;
        Inlined version of run_machine for speed.
        )Nrrrr
rrzState %d, %d/%d:%s -->�numberr'N�elsezState %drir
�
r���ZblockedzDoing %s)rrrrrrrr
r�lenrr,�repr�getrrrr*rrr)r �staterrrrrrr
rZbuf_lenZb_actionZ	b_cur_posZ
b_cur_lineZb_cur_line_startZ
b_cur_charZ
b_input_stateZ
b_next_posrr'�cZ	new_stateZ	buf_index�discard�datar!r!r"r+�s� 










zScanner.run_machine_inlinedcCs�|j}|jr tdd||jf�|dkrh|j|_|��}|dkrNt|_d|_q�|s`t|_d|_q�||_nd|dkr~d|_d|_nN|dkr�|jd7_|j|_	|_t
|_d|_n|dkr�t|_d|_nd	|_|jr�td
||jt|j�f�dS)NzScanner: next: %s [%d] %dz                    rr0rr1r2r3r
z--> [%d] %d %s)
rrr,rrZ	read_charrrrrrrr5)r rr8r!r!r"r-	s6zScanner.next_charcCs|j|j|jfS)am
        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).
        )rrr)r r!r!r"�position(s	zScanner.positioncCs|��S)zOPython accessible wrapper around position(), only for error reporting.
        )r;)r r!r!r"�get_position3szScanner.get_positioncCs|j�|�|_||_dS)z8Set the current state of the scanner to the named state.N)rZget_initial_staterr)r rr!r!r"r8sz
Scanner.begincCs"|dkr|j}|j�||f�dS)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)rr�append)r r(rr!r!r"r%>szScanner.producecCsdS)z_
        Override this method if you want something to be done at
        end of file.
        Nr!)r r!r!r"r&MszScanner.eof)r
N)N)�__name__�
__module__�__qualname__�__doc__r#r*r$r+r-r;r<rr%r&r!r!r!r"r	s
(j
r	)
�
__future__r�cython�declare�objectr
rZRegexpsrrrrr	r!r!r!r"�<module>
s