Hacked By AnonymousFox

Current Path : /opt/alt/python310/lib64/python3.10/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/lib2to3/pgen2/__pycache__/driver.cpython-310.pyc

o

6��fQ�@s�dZdZddgZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZm
Z
Gdd�de�Zd	d
�Z		ddd�Zdd�Zdd�Zdd�ZedkrXe�ee���dSdS)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&||_|durt��}||_||_dS)N)r�logging�	getLogger�logger�convert)�selfrr
r�r�;/opt/alt/python310/lib64/python3.10/lib2to3/pgen2/driver.py�__init__s

zDriver.__init__FcCs�t�|j|j�}|��d}d}d}}}}	}
d}|D]�}|\}}}}	}
|||fkr]||f|ks;J||f|f��|\}
}||
krO|d|
|7}|
}d}||kr]||
||�7}|}|tjtjfvry||7}|	\}}|�d�rx|d7}d}q|t	j
kr�tj|}|r�|j�
dt	j|||�|�||||f�r�|r�|j�
d�|jSd}|	\}}|�d�r�|d7}d}qt�d||||f��)	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&sZ


�
�
�
�zDriver.parse_tokenscCst�|j�}|�||�S�z*Parse a stream and return the syntax tree.)r�generate_tokens�readliner#)r�streamrrrrr�parse_stream_rawVszDriver.parse_stream_rawcCs|�||�Sr$)r()rr'rrrr�parse_stream[szDriver.parse_streamcCs@tj|d|d��}|�||�Wd�S1swYdS)z(Parse a file and return the syntax tree.�r)�encodingN)�io�openr))r�filenamer+rr'rrr�
parse_file_s
$�zDriver.parse_filecCst�t�|�j�}|�||�S)z*Parse a string and return the syntax tree.)rr%r,�StringIOr&r#)r�textrrrrr�parse_stringdszDriver.parse_string)NN)F)NF)	�__name__�
__module__�__qualname__rr#r(r)r/r2rrrrrs


0

cCs:tj�|�\}}|dkrd}||d�tttj��dS)Nz.txtr�.z.pickle)�os�path�splitext�join�map�str�sys�version_info)�gt�head�tailrrr�_generate_pickle_namejsrB�Grammar.txtTFc
Cs�|durt��}|durt|�n|}|st||�sP|�d|�t�|�}|rN|�d|�z|�|�W|StyM}z
|�d|�WYd}~|Sd}~ww|St	�
�}|�|�|S)z'Load the grammar (maybe from a pickle).Nz!Generating grammar tables from %szWriting grammar tables to %szWriting failed: %s)r
rrB�_newer�infor	Zgenerate_grammar�dump�OSErrorr�Grammar�load)r?Zgp�save�forcer�g�errrrqs(
����
cCs8tj�|�sdStj�|�sdStj�|�tj�|�kS)z0Inquire whether file a was written since file b.FT)r7r8�exists�getmtime)�a�brrrrD�s
rDcCsFtj�|�r
t|�Sttj�|��}t�||�}t�	�}|�
|�|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.

    )r7r8�isfilerrB�basename�pkgutil�get_datarrH�loads)�packageZgrammar_sourceZpickled_name�datarLrrr�load_packaged_grammar�s
rYcGsB|s	tjdd�}tjtjtjdd�|D]	}t|ddd�qdS)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)rJrK)r=�argvr
ZbasicConfig�INFO�stdoutr)�argsr?rrr�main�s�r`�__main__)rCNTFN)�__doc__�
__author__�__all__r,r7r
rTr=rrrrrr	�objectrrBrrDrYr`r3�exit�intrrrr�<module>s(M
�	
�

Hacked By AnonymousFox1.0, Coded By AnonymousFox