Your IP : 18.225.55.42


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.pyc

�
��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
	s�|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�S|j�jj
ks�t�d}|j}t|�dkr�|djtjkr�|dj}|dd�}nd}t|�dkr,|d
j�jjkr,|d}|dd�}n�j||�}|dk	r�|j�jjkset�|j}	|	d}
|
jtjkr�d}tj}n�|
jtjkr�d}tj}n�|
jtjkrH|	djtjks�t�t|	�dkst��j|	d�}}t|	�dkrT�j|	d�}qTndsTt�|dksl|dkr�|j�}tj|ggd|d	|�}q�n|dk	r�||_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����i����(iiF(utypeusymsuMatcheruchildrenuAlternativesulenupytreeuWildcardPatternuoptimizeuAlternativeuNegatedUnitu
compile_basicuNegatedPatternuUnituAssertionErroruNoneutokenuEQUALuvalueuRepeateruSTARuHUGEuPLUSuLBRACEuRBRACEuget_intuFalseuname(
uselfunodeualtsupuunitsupatternunameunodesurepeatuchildrenuchilduminumax((uselfu4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyucompile_nodeDsh)(


	(
+
	
'uPatternCompiler.compile_nodecCst|�dkst�|d}|jtjkrbttj|j��}t	j
t|�|�S|jtjkr||j}|j
�r�|tkr�td|��n|dd�r�td��nt	j
t|�S|dkr�d}nF|jd�s3t|j|d�}|dkr3td|��q3n|dd�rc|j|djd�g}nd}t	j||�Sns|jdkr�|j|d�S|jd	kr�|dks�t�|j|d�}t	j|ggd
ddd�Sdst|��dS(
NiiuInvalid token: %ruCan't have details for tokenuanyu_uInvalid symbol: %ru(u[uminumaxF(ulenuAssertionErrorutypeutokenuSTRINGustruliteralsu
evalStringuvalueupytreeuLeafPatternu_type_of_literaluNAMEuisupperu	TOKEN_MAPuPatternSyntaxErroruNoneu
startswithugetattrupysymsucompile_nodeuchildrenuNodePatternuWildcardPatternuFalse(uselfunodesurepeatunodeuvalueutypeucontentu
subpattern((u4/opt/alt/python33/lib64/python3.3/lib2to3/patcomp.pyu
compile_basic�s<
		 uPatternCompiler.compile_basiccCs%|jtjkst�t|j�S(N(utypeutokenuNUMBERuAssertionErroruintuvalue(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$.	
�



		

?>