ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/lib2to3/__pycache__/patcomp.cpython-35.opt-2.pyc



���]��@sdZddlZddlZddlmZmZmZmZmZm	Z	ddl
mZddl
mZej
jej
je�d�ZGdd	�d	e�Zd
d�ZGdd
�d
e�ZdejdejdejddiZdd�Zdd�Zdd�ZdS)z#Guido van Rossum <guido@python.org>�N�)�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramzPatternGrammar.txtc@seZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__�rr�,/opt/alt/python35/lib64/python3.5/patcomp.pyrsrc	csntjtjtjh}tjtj|�j�}x4|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_wrapper!s
rc@sXeZdZedd�Zdddd�Zdd�Zdd	d
�Zdd�ZdS)
�PatternCompilercCs^tj|�|_tj|j�|_tj|_tj|_	tj
|jdt�|_dS)N�convert)rZload_grammarrr
ZSymbols�symsZpython_grammarZ	pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filerrr�__init__-s
zPatternCompiler.__init__FcCs�t|�}y|jj|d|�}Wn:tjk
rd}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_pattern8s%zPatternCompiler.compile_patternc
s6|j�jjkr"|jd}|j�jjkr��fdd�|jddd�D�}t|�dkrz|dStjdd�|D�dddd�}|j�S|j�jj	kr�fd	d�|jD�}t|�dkr�|dStj|gdddd�}|j�S|j�jj
kri�j|jdd��}tj|�}|j�Sd}|j}t|�d
kr�|djt
jkr�|dj}|dd�}d}t|�dkr|dj�jjkr|d
}|dd�}�j||�}|dk	r|j}	|	d}
|
jt
jkr]d}tj}nu|
jt
jkr�d}tj}nQ|
jt
jkr��j|	d�}}t|	�dkr��j|	d
�}n|dks�|dkr|j�}tj|ggd|d|�}|dk	r,||_|j�S)Nrcsg|]}�j|��qSr)r))�.0�ch)r%rr�
<listcomp>Ps	z0PatternCompiler.compile_node.<locals>.<listcomp>�rcSsg|]}|g�qSrr)r-�arrrr/Ss	�min�maxcsg|]}�j|��qSr)r))r-r.)r%rrr/Ws	�����r6r6)rr"ZMatcher�childrenZAlternatives�lenr	�WildcardPattern�optimizeZAlternativeZNegatedUnit�
compile_basicZNegatedPatternr�EQUALrZRepeater�STARZHUGE�PLUS�LBRACE�get_int�name)
r%�nodeZalts�pZunits�patternrA�nodes�repeatr7Zchildr2r3r)r%rr)Ds^
)(


	(
+
	
!	zPatternCompiler.compile_nodeNcCs�|d}|jtjkrJttj|j��}tjt	|�|�S|jtj
krX|j}|j�r�|tkr�t
d|��|dd�r�t
d��tjt|�S|dkr�d}n@|jd�st|j|d�}|dkrt
d|��|dd�r?|j|djd�g}nd}tj||�Sna|jdkrx|j|d�S|jd	kr�|j|d�}tj|ggd
ddd�SdS)NrzInvalid token: %rrzCan't have details for token�any�_zInvalid symbol: %r�(�[r2r3)rr�STRINGr(rZ
evalStringrr	ZLeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr�
startswith�getattrr#r)r7ZNodePatternr9)r%rErFrBrrZcontent�
subpatternrrrr;�s8
		 zPatternCompiler.compile_basiccCs
t|j�S)N)�intr)r%rBrrrr@�szPatternCompiler.get_int)	rr
r�_PATTERN_GRAMMAR_FILEr&r,r)r;r@rrrrr +s
G#r rMrK�NUMBERZTOKENcCs9|dj�rtjS|tjkr1tj|SdSdS)Nr)�isalpharrMrZopmap)rrrrrL�s
rLcCsW|\}}}}|s'||jkr=tj||d|�Stj||d|�SdS)N�context)Z
number2symbolr	ZNodeZLeaf)rZ
raw_node_inforrrWr7rrrr$�sr$cCst�j|�S)N)r r,)rDrrrr,�sr,)�
__author__r�osZpgen2rrrrrr�r	r
�path�join�dirname�__file__rT�	Exceptionrr�objectr rMrKrUrOrLr$r,rrrr�<module>s".	
�					

Zerion Mini Shell 1.0