Your IP : 3.15.218.44


Current Path : /opt/alt/python33/lib64/python3.3/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/lib2to3/__pycache__/patcomp.cpython-33.pyo

�
��f�c@sdZdZddlZddlZddlmZmZmZmZm	Z	m
Z
ddlmZddlm
Z
ejjejje�d�ZGd	d
�d
e�Zdd�ZGd
d�de�Ziejd6ejd6ejd6dd6Zdd�Zdd�Zdd�ZdS(u�Pattern compiler.

The grammer is taken from PatternGrammar.txt.

The compiler compiles a pattern to a pytree.*Pattern instance.
u#Guido van Rossum <guido@python.org>iNi(udriveruliteralsutokenutokenizeuparseugrammar(upytree(upygramuPatternGrammar.txtcBs|EeZdZdS(uPatternSyntaxErrorN(u__name__u
__module__u__qualname__(u
__locals__((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyuPatternSyntaxErrorsuPatternSyntaxErrorc	cswttjtjtjf�}tjtj|�j	�}x7|D]/}|\}}}}}||kr@|Vq@q@WdS(u6Tokenizes a string suppressing significant whitespace.N(
usetutokenuNEWLINEuINDENTuDEDENTutokenizeugenerate_tokensuiouStringIOureadline(	uinputuskiputokensu	quintupleutypeuvalueustartuendu	line_text((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyutokenize_wrapper!s
utokenize_wrappercBs\|EeZdZedd�Zdddd�Zdd�Zddd�Z	d	d
�Z
dS(
uPatternCompilercCs^tj|�|_tj|j�|_tj|_tj|_	tj
|jdt�|_dS(u^Initializer.

        Takes an optional alternative filename for the pattern grammar.
        uconvertN(udriveruload_grammarugrammarupygramuSymbolsusymsupython_grammaru	pygrammarupython_symbolsupysymsuDriverupattern_convert(uselfugrammar_file((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyu__init__-s
uPatternCompiler.__init__cCs�t|�}y|jj|d|�}Wn:tjk
rd}ztt|���WYdd}~XnX|r~|j|�|fS|j|�SdS(u=Compiles a pattern string to a nested pytree.*Pattern object.udebugN(utokenize_wrapperudriveruparse_tokensuparseu
ParseErroruPatternSyntaxErrorustrucompile_node(uselfuinputudebugu	with_treeutokensurootue((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyucompile_pattern8s%uPatternCompiler.compile_patternc
	sK|j�jjkr%|jd}n|j�jjkr��fdd�|jddd�D�}t|�dkr}|dStjdd�|D�ddd	d�}|j�S|j�jj	kr"�fd
d�|jD�}t|�dkr�|dStj|gddd	d�}|j�S|j�jj
krl�j|jdd��}tj|�}|j�Sd}|j}t|�dkr�|djtjkr�|dj}|dd�}nd}t|�dkr|d
j�jjkr|d}|dd�}n�j||�}|dk	r)|j}	|	d}
|
jtjkrfd}tj}nx|
jtjkr�d}tj}nT|
jtjkr��j|	d�}}t|	�dkr��j|	d�}q�n|dks�|dkr)|j�}tj|ggd|d	|�}q)n|dk	rA||_n|j�S(uXCompiles a node, recursively.

        This is one big switch on the node type.
        icsg|]}�j|��qS((ucompile_node(u.0uch(uself(u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyu
<listcomp>Ps	u0PatternCompiler.compile_node.<locals>.<listcomp>NiicSsg|]}|g�qS(((u.0ua((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyu
<listcomp>Ss	uminumaxcsg|]}�j|��qS((ucompile_node(u.0uch(uself(u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyu
<listcomp>Ws	iii����i����i����(utypeusymsuMatcheruchildrenuAlternativesulenupytreeuWildcardPatternuoptimizeuAlternativeuNegatedUnitu
compile_basicuNegatedPatternuNoneutokenuEQUALuvalueuRepeateruSTARuHUGEuPLUSuLBRACEuget_intuname(
uselfunodeualtsupuunitsupatternunameunodesurepeatuchildrenuchilduminumax((uselfu4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyucompile_nodeDs^)(


	(
+
	
'uPatternCompiler.compile_nodecCs�|d}|jtjkrJttj|j��}tjt	|�|�S|jtj
krd|j}|j�r�|tkr�t
d|��n|dd�r�t
d��ntjt|�S|dkr�d}nF|jd�st|j|d�}|dkrt
d|��qn|dd�rK|j|djd�g}nd}tj||�Sna|jdkr�|j|d�S|jd	kr�|j|d�}tj|ggd
ddd�SdS(NiuInvalid token: %riuCan't have details for tokenuanyu_uInvalid symbol: %ru(u[uminumax(utypeutokenuSTRINGustruliteralsu
evalStringuvalueupytreeuLeafPatternu_type_of_literaluNAMEuisupperu	TOKEN_MAPuPatternSyntaxErroruNoneu
startswithugetattrupysymsucompile_nodeuchildrenuNodePatternuWildcardPattern(uselfunodesurepeatunodeuvalueutypeucontentu
subpattern((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyu
compile_basic�s8
		 uPatternCompiler.compile_basiccCs
t|j�S(N(uintuvalue(uselfunode((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyuget_int�suPatternCompiler.get_intNF(u__name__u
__module__u__qualname__u_PATTERN_GRAMMAR_FILEu__init__uFalseucompile_patternucompile_nodeuNoneu
compile_basicuget_int(u
__locals__((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyuPatternCompiler+s
G#uPatternCompileruNAMEuSTRINGuNUMBERuTOKENcCs9|dj�rtjS|tjkr1tj|SdSdS(Ni(uisalphautokenuNAMEugrammaruopmapuNone(uvalue((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyu_type_of_literal�s
u_type_of_literalcCsW|\}}}}|s'||jkr=tj||d|�Stj||d|�SdS(u9Converts raw node information to a Node or Leaf instance.ucontextN(u
number2symbolupytreeuNodeuLeaf(ugrammaru
raw_node_infoutypeuvalueucontextuchildren((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyupattern_convert�supattern_convertcCst�j|�S(N(uPatternCompilerucompile_pattern(upattern((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyucompile_pattern�sucompile_pattern( u__doc__u
__author__uiouosupgen2udriveruliteralsutokenutokenizeuparseugrammaruupytreeupygramupathujoinudirnameu__file__u_PATTERN_GRAMMAR_FILEu	ExceptionuPatternSyntaxErrorutokenize_wrapperuobjectuPatternCompileruNAMEuSTRINGuNUMBERuNoneu	TOKEN_MAPu_type_of_literalupattern_convertucompile_pattern(((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyu<module>	s$.	
�



		

?>