ok

Mini Shell

Direktori : /proc/self/root/lib64/python3.6/lib2to3/__pycache__/
Upload File :
Current File : //proc/self/root/lib64/python3.6/lib2to3/__pycache__/patcomp.cpython-36.opt-2.pyc

3


 \��@s�dZddlZddlmZmZmZmZmZmZddl	m
Z
ddl	mZGdd�de�Z
d	d
�ZGdd�de�Zejejejdd
�Zdd�Zdd�Zdd�ZdS)z#Guido van Rossum <guido@python.org>�N�)�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramc@seZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__�rr�'/usr/lib64/python3.6/lib2to3/patcomp.pyrsrc	csPtjtjtjh}tjtj|�j�}x(|D] }|\}}}}}||kr(|Vq(WdS)N)	r�NEWLINE�INDENT�DEDENTr�generate_tokens�io�StringIO�readline)	�input�skip�tokensZ	quintuple�type�value�start�endZ	line_textrrr�tokenize_wrappers
rc@s:eZdZd
dd�Zddd�Zdd�Zdd	d
�Zdd�ZdS)�PatternCompilerNcCsZ|dkrtj|_tj|_ntj|�|_tj|j�|_tj|_	tj
|_tj|jt
d�|_dS)N)Zconvert)r
Zpattern_grammarrZpattern_symbols�symsrZload_grammarZSymbolsZpython_grammarZ	pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filerrr�__init__(s
zPatternCompiler.__init__FcCsnt|�}y|jj||d�}Wn0tjk
rL}ztt|���WYdd}~XnX|r`|j|�|fS|j|�SdS)N)�debug)rrZparse_tokensrZ
ParseErrorr�str�compile_node)r$rr&Z	with_treer�root�errr�compile_pattern7szPatternCompiler.compile_patternc
sV|j�jjkr|jd}|j�jjkrz�fdd�|jddd�D�}t|�dkrX|dStjdd�|D�ddd�}|j�S|j�jj	krʇfdd�|jD�}t|�dkr�|dStj|gddd�}|j�S|j�jj
kr��j|jdd��}tj|�}|j�Sd}|j}t|�d	k�r>|djt
jk�r>|dj}|dd�}d}t|�dk�rx|dj�jjk�rx|d}|dd
�}�j||�}|dk	�r>|j}	|	d}
|
jt
jk�r�d}tj}nX|
jt
jk�r�d}tj}n>|
jt
jk�r�j|	d�}}t|	�d
k�r�j|	d	�}n|dk�s"|dk�r>|j�}tj|gg||d�}|dk	�rN||_|j�S)Nrcsg|]}�j|��qSr)r()�.0�ch)r$rr�
<listcomp>Osz0PatternCompiler.compile_node.<locals>.<listcomp>�rcSsg|]
}|g�qSrr)r,�arrrr.Rs)�min�maxcsg|]}�j|��qSr)r()r,r-)r$rrr.Vs�����r5r5)rr!ZMatcher�childrenZAlternatives�lenr	�WildcardPattern�optimizeZAlternativeZNegatedUnit�
compile_basicZNegatedPatternr�EQUALrZRepeater�STARZHUGE�PLUS�LBRACE�get_int�name)
r$�nodeZalts�pZunits�patternr@�nodes�repeatr6Zchildr1r2r)r$rr(Cs^

 
"

zPatternCompiler.compile_nodecCs@|d}|jtjkr4ttj|j��}tjt	|�|�S|jtj
kr�|j}|j�r�|tkrbt
d|��|dd�rvt
d��tjt|�S|dkr�d}n,|jd�s�t|j|d�}|dkr�t
d|��|dd�r�|j|djd�g}nd}tj||�SnH|jdk�r|j|d�S|jd	k�r<|j|d�}tj|ggddd
�SdS)NrzInvalid token: %rrzCan't have details for token�any�_zInvalid symbol: %r�(�[)r1r2)rr�STRINGr'rZ
evalStringrr	ZLeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr�
startswith�getattrr"r(r6ZNodePatternr8)r$rDrErArrZcontent�
subpatternrrrr:�s8
zPatternCompiler.compile_basiccCs
t|j�S)N)�intr)r$rArrrr?�szPatternCompiler.get_int)N)FF)N)rr
rr%r+r(r:r?rrrrr &s


G
#r )rLrJ�NUMBERZTOKENcCs.|dj�rtjS|tjkr&tj|SdSdS)Nr)�isalpharrLrZopmap)rrrrrK�s


rKcCs>|\}}}}|s||jkr*tj|||d�Stj|||d�SdS)N)�context)Z
number2symbolr	ZNodeZLeaf)rZ
raw_node_inforrrUr6rrrr#�sr#cCst�j|�S)N)r r+)rCrrrr+�sr+)�
__author__rZpgen2rrrrrr�r	r
�	Exceptionrr�objectr rLrJrSrNrKr#r+rrrr�<module>s 
		

Zerion Mini Shell 1.0