Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/Cython/Plex/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/Cython/Plex/__pycache__/Scanners.cpython-35.pyc



Z��Z�/�	@s�ddlmZddlZejdededede�ddlmZdd	lmZm	Z	m
Z
e�ZGd
d�de�ZdS)�)�absolute_importN�BOL�EOL�EOF�	NOT_FOUND�)�Errors)rrrc@s�eZdZdZdddd�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|_|jd�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/python35/lib64/python3.5/site-packages/Cython/Plex/Scanners.py�__init__Hs0
																
					zScanner.__init__cCs�|j}xs|s~|j�\|_}|dkrM|jd�|j�q|j||j�}|dk	r|j|�qW|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|_|j�}|dk	r�|jritd||j|jf�|j	|j|j
|j|j
�}||fS|j|jkr�|jtkr�|j
�|jdks�|jtkr�dStj||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:%dr
)r
N)rrrrrr�run_machine_inlinedr�printr
rrr�	next_charrrZUnrecognizedInputr)r r'rr!r!r"r$�s$	


zScanner.scan_a_tokencCsv|j}|j}|j}|j}|j}|j}|j}|j}|j}	t	|�}
d\}}}
}}}}|j
}x�|r�td|d||t|�f�|d}|dk	r�|||||||f\}}}
}}}}|}|j
|t�}|tkr-|o*|j
d�}|r�|rKtd|d�|}|d	krT|}||	}||
kr�||}|d	7}n�|j|	}|jjd
�}|j|d�|}||_|	|7}	|	|_t	|�}
||8}|r||}|d	7}nd}|dkr6t}d}q�|sKt}d
}q�|}q|dkrod}d}q|dkr�|d	7}|}}t}d	}q|d
kr�t}d}qd}q�|r�td�|dk	r|||
||||f\}}}}}}}nd}Pq�W||_||_||_||_||_||_|rr|dk	rrtd|�|S)z;
        Inlined version of run_machine for speed.
        Nrr
zState %d, %d/%d:%s -->�numberr'�elsezState %dri�
r���ZblockedzDoing %s)Nrrrr
rr)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�										
0



	
	


				

			
'						zScanner.run_machine_inlinedcCsV|j}|jr,tdd||jf�|dkr�|j|_|j�}|dkrqt|_d|_q&|s�t|_d|_q&||_n�|dkr�d|_d|_nm|dkr�|jd7_|j|_	|_t
|_d|_n*|dkrt|_d	|_n	d
|_|jrRtd||jt|j�f�dS)
NzScanner: next: %s [%d] %d� �rr0rr1r2r3r
z--> [%d] %d %sz                    )
rrr,rrZ	read_charrrrrrrr5)r rr8r!r!r"r-	s6									zScanner.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
|j�S)zOPython accessible wrapper around position(), only for error reporting.
        )r=)r r!r!r"�get_position3szScanner.get_positioncCs"|jj|�|_||_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}|jj||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%>s	zScanner.producecCsdS)z_
        Override this method if you want something to be done at
        end of file.
        Nr!)r r!r!r"r&MszScanner.eof)�__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"