Hacked By AnonymousFox

Current Path : /opt/alt/python36/lib64/python3.6/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/lib2to3/pgen2/__pycache__/driver.cpython-36.opt-1.pyc

3

� f��@s�dZdZddgZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZGdd�de�Zd	d
�Zddd�Zdd�Zdd�Zdd�Zedkr�ejee���dS)zZParser driver.

This provides a high-level interface to parse a file into a syntax tree.

z#Guido van Rossum <guido@python.org>�Driver�load_grammar�N�)�grammar�parse�token�tokenize�pgenc@sHeZdZddd�Zddd�Zddd�Zdd	d
�Zddd�Zdd
d�ZdS)rNcCs&||_|dkrtj�}||_||_dS)N)r�logging�	getLogger�logger�convert)�selfrr
r�r�9/opt/alt/python36/lib64/python3.6/lib2to3/pgen2/driver.py�__init__ s
zDriver.__init__FcCsvtj|j|j�}|j�d}d}d}}}}	}
d}�x4|D�]}|\}}}}	}
|||fkr�|\}
}||
kr�|d|
|7}|
}d}||kr�||
||�7}|}|tjtjfkr�||7}|	\}}|jd�r@|d7}d}q@|t	j
kr�tj|}|�r|jj
dt	j|||�|j||||f��r6|�r4|jj
d�Pd}|	\}}|jd�r@|d7}d}q@Wtjd||||f��|jS)	z4Parse a series of tokens and return the syntax tree.rrN��
z%s %r (prefix=%r)zStop.zincomplete input)rZParserrr
Zsetupr�COMMENT�NL�endswithr�OPZopmapr�debug�tok_nameZaddtokenZ
ParseErrorZrootnode)r�tokensr�p�lineno�column�type�value�start�endZ	line_text�prefixZ	quintupleZs_linenoZs_columnrrr�parse_tokens'sR



zDriver.parse_tokenscCstj|j�}|j||�S)z*Parse a stream and return the syntax tree.)r�generate_tokens�readliner#)r�streamrrrrr�parse_stream_rawWszDriver.parse_stream_rawcCs|j||�S)z*Parse a stream and return the syntax tree.)r')rr&rrrr�parse_stream\szDriver.parse_streamc
Cs*tj|d|�}z|j||�S|j�XdS)z(Parse a file and return the syntax tree.�rN)�codecs�openr(�close)r�filename�encodingrr&rrr�
parse_file`szDriver.parse_filecCstjtj|�j�}|j||�S)z*Parse a string and return the syntax tree.)rr$�io�StringIOr%r#)r�textrrrrr�parse_stringhszDriver.parse_string)NN)F)F)F)NF)F)	�__name__�
__module__�__qualname__rr#r'r(r/r3rrrrrs

0


cCs:tjj|�\}}|dkrd}||djtttj��dS)Nz.txtr�.z.pickle)�os�path�splitext�join�map�str�sys�version_info)�gt�head�tailrrr�_generate_pickle_namensrC�Grammar.txtTFcCs�|dkrtj�}|dkr t|�n|}|s4t||�r�|jd|�tj|�}|r�|jd|�y|j|�Wq�tk
r�}z|jd|�WYdd}~Xq�Xnt	j
�}|j|�|S)z'Load the grammar (maybe from a pickle).Nz!Generating grammar tables from %szWriting grammar tables to %szWriting failed: %s)r
rrC�_newer�infor	Zgenerate_grammar�dump�OSErrorr�Grammar�load)r@Zgp�save�forcer�g�errrrus
 
cCs8tjj|�sdStjj|�s dStjj|�tjj|�kS)z0Inquire whether file a was written since file b.FT)r8r9�exists�getmtime)�a�brrrrE�s
rEcCsFtjj|�rt|�Sttjj|��}tj||�}tj	�}|j
|�|S)a�Normally, loads a pickled grammar by doing
        pkgutil.get_data(package, pickled_grammar)
    where *pickled_grammar* is computed from *grammar_source* by adding the
    Python version and using a ``.pickle`` extension.

    However, if *grammar_source* is an extant file, load_grammar(grammar_source)
    is called instead. This facilitates using a packaged grammar file when needed
    but preserves load_grammar's automatic regeneration behavior when possible.

    )r8r9�isfilerrC�basename�pkgutil�get_datarrI�loads)�packageZgrammar_sourceZpickled_name�datarMrrr�load_packaged_grammar�s
rZcGsF|stjdd�}tjtjtjdd�x|D]}t|ddd�q,WdS)z�Main program, when run as a script: produce grammar pickle files.

    Calls load_grammar for each argument, a path to a grammar text file.
    rNz%(message)s)�levelr&�formatT)rKrL)r>�argvr
ZbasicConfig�INFO�stdoutr)�argsr@rrr�main�s
ra�__main__)rDNTFN)�__doc__�
__author__�__all__r*r0r8r
rUr>rrrrrr	�objectrrCrrErZrar4�exit�intrrrr�<module>s$P
	


Hacked By AnonymousFox1.0, Coded By AnonymousFox