AlkantarClanX12

Your IP : 3.145.177.173


Current Path : /proc/self/root/usr/lib/python3.6/site-packages/ply/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3.6/site-packages/ply/__pycache__/yacc.cpython-36.pyc

3

.[�`F�
@sddlZddlZddlZddlZddlZddlZddlZdZdZ	dZ
dZdZdZ
dZd	Zd
ZdZejddkrteZneZejZGdd�de�ZGd
d�de�ZGdd�de�Zdd�Zdd�Zdada da!dZ"dd�Z#dd�Z$dd�Z%dd�Z&Gdd�d�Z'Gd d!�d!�Z(Gd"d#�d#�Z)ej*d$�Z+Gd%d&�d&e�Z,Gd'd(�d(e�Z-Gd)d*�d*e�Z.d+d,�Z/Gd-d.�d.e�Z0Gd/d0�d0e�Z1Gd1d2�d2e�Z2Gd3d4�d4e�Z3d5d6�Z4d7d8�Z5Gd9d:�d:e�Z6Gd;d<�d<e3�Z7d=d>�Z8d?d@�Z9GdAdB�dBe�Z:de
deddd	deddddf
dCdD�Z;dS)E�Nz3.9z3.8Tz
parser.out�parsetab�LALR�F�(c@s4eZdZdd�Zdd�ZeZdd�Zdd�ZeZd	S)
�	PlyLoggercCs
||_dS)N)�f)�selfr�r	�/usr/lib/python3.6/yacc.py�__init__nszPlyLogger.__init__cOs|jj||d�dS)N�
)r�write)r�msg�args�kwargsr	r	r
�debugqszPlyLogger.debugcOs|jjd||d�dS)Nz	WARNING: r)rr
)rrrrr	r	r
�warningvszPlyLogger.warningcOs|jjd||d�dS)NzERROR: r)rr
)rrrrr	r	r
�erroryszPlyLogger.errorN)	�__name__�
__module__�__qualname__rr�inforrZcriticalr	r	r	r
rmsrc@seZdZdd�Zdd�ZdS)�
NullLoggercCs|S)Nr	)r�namer	r	r
�__getattribute__�szNullLogger.__getattribute__cOs|S)Nr	)rrrr	r	r
�__call__�szNullLogger.__call__N)rrrrrr	r	r	r
rsrc@seZdZdS)�	YaccErrorN)rrrr	r	r	r
r�srcCsPt|�}d|krt|�}t|�tkr4|dt�d}dt|�jt|�|f}|S)Nrz ...z<%s @ 0x%x> (%s))�repr�len�resultlimit�typer�id)�r�repr_str�resultr	r	r
�
format_result�sr%cCsBt|�}d|krt|�}t|�dkr(|Sdt|�jt|�fSdS)Nr�z<%s @ 0x%x>)rrr rr!)r"r#r	r	r
�format_stack_entry�sr'aPLY: Don't use global functions errok(), token(), and restart() in p_error().
Instead, invoke the methods on the associated parser instance:

    def p_error(p):
        ...
        # Use parser.errok(), parser.token(), parser.restart()
        ...

    parser = yacc.yacc()
cCstjt�t�S)N)�warnings�warn�_warnmsg�_errokr	r	r	r
�errok�s
r,cCstjt�t�S)N)r(r)r*�_restartr	r	r	r
�restart�s
r.cCstjt�t�S)N)r(r)r*�_tokenr	r	r	r
�token�s
r0cCs>|ja|ja|ja||�}y
bbbWntk
r8YnX|S)N)r,r+r0r/r.r-�	NameError)�	errorfuncr0�parserr"r	r	r
�call_errorfunc�s
r4c@seZdZdd�Zdd�ZdS)�
YaccSymbolcCs|jS)N)r )rr	r	r
�__str__�szYaccSymbol.__str__cCst|�S)N)�str)rr	r	r
�__repr__�szYaccSymbol.__repr__N)rrrr6r8r	r	r	r
r5�sr5c@sfeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�YaccProductionNcCs||_||_d|_d|_dS)N)�slice�stack�lexerr3)r�sr;r	r	r
r�szYaccProduction.__init__cCsBt|t�rdd�|j|D�S|dkr2|j|jS|j|jSdS)NcSsg|]
}|j�qSr	)�value)�.0r=r	r	r
�
<listcomp>�sz.YaccProduction.__getitem__.<locals>.<listcomp>r)�
isinstancer:r>r;)r�nr	r	r
�__getitem__�s

zYaccProduction.__getitem__cCs||j|_dS)N)r:r>)rrB�vr	r	r
�__setitem__�szYaccProduction.__setitem__cCsdd�|j||�D�S)NcSsg|]
}|j�qSr	)r>)r?r=r	r	r
r@�sz/YaccProduction.__getslice__.<locals>.<listcomp>)r:)r�i�jr	r	r
�__getslice__�szYaccProduction.__getslice__cCs
t|j�S)N)rr:)rr	r	r
�__len__�szYaccProduction.__len__cCst|j|dd�S)N�linenor)�getattrr:)rrBr	r	r
rJszYaccProduction.linenocCs||j|_dS)N)r:rJ)rrBrJr	r	r
�
set_linenoszYaccProduction.set_linenocCs,t|j|dd�}t|j|d|�}||fS)NrJr�	endlineno)rKr:)rrB�	startlineZendliner	r	r
�linespanszYaccProduction.linespancCst|j|dd�S)N�lexposr)rKr:)rrBr	r	r
rPszYaccProduction.lexposcCs,t|j|dd�}t|j|d|�}||fS)NrPr�	endlexpos)rKr:)rrB�startpos�endposr	r	r
�lexspanszYaccProduction.lexspancCst�dS)N)�SyntaxError)rr	r	r
rszYaccProduction.error)N)rrrrrCrErHrIrJrLrOrPrTrr	r	r	r
r9�s
r9c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd
d�Zddd�Z	ddd�Z
ddd�ZdS)�LRParsercCs0|j|_|j|_|j|_||_|j�d|_dS)NT)	�lr_productions�productions�	lr_action�action�lr_goto�gotor2�set_defaulted_states�errorok)rZlrtabZerrorfr	r	r
rszLRParser.__init__cCs
d|_dS)NT)r^)rr	r	r
r,&szLRParser.errokcCs@|jdd�=|jdd�=t�}d|_|jj|�|jjd�dS)Nz$endr)�
statestack�symstackr5r �append)r�symr	r	r
r.)szLRParser.restartcCsTi|_xH|jj�D]:\}}t|j��}t|�dkr|ddkr|d|j|<qWdS)N�r)�defaulted_statesrZ�items�list�valuesr)r�state�actionsZrulesr	r	r
r]9s
zLRParser.set_defaulted_statescCs
i|_dS)N)rd)rr	r	r
�disable_defaulted_states@sz!LRParser.disable_defaulted_statesNFcCsZ|str.t|t�rttj�}|j|||||�S|rD|j|||||�S|j|||||�SdS)N)	�	yaccdevelrA�intr�sys�stderr�
parsedebug�parseopt�parseopt_notrack)r�inputr<r�tracking�	tokenfuncr	r	r
�parseCs

zLRParser.parsec Cs�d}g}|j}|j}	|j}
|j}td�}d}
|jd�|sLddlm}|j}||_||_	|dk	rj|j
|�|dkrz|j}n|}||_g}||_g}||_
||_d}|jd�t�}d|_|j|�d}�x�|jd�|jd|�||k�r.|�s|�s�|�}n|j�}|�st�}d|_|j}||j|�}n||}|jd||�|jd	d
djdd
�|D�dd��t|�fj��|dk	�r�|dk�r�|j|�|}|jd|�|j|�d}|
r�|
d8}
q�|dk�rN|
|}|j}|j}t�}||_d|_|�rB|jd|jddjdd
�||d�D��d|	|d%||�n|jd|jg|	|d&|�|�r�||dd�}||d<|�r�|d}|j|_|j|_|d'}t|d|j�|_t|d|j�|_||_ yd||d�=||_!|j"|�||d�=|jdt#|d��|j|�|	|d(|}|j|�Wq�t$k
�r�|j|�|j%|dd)��|j�|d*}d|_d|_|}t&}
d|_'Yq�Xq�n�|�r�|j|_|j|_|g}||_ yL||_!|j"|�|jdt#|d��|j|�|	|d+|}|j|�Wq�t$k
�rJ|j|�|j�|d,}d|_d|_|}t&}
d|_'Yq�Xq�|dk�r�|d-}t|dd�}|jdt#|��|jd�|S|dk�r�|j(dd
djdd
�|D�dd��t|�fj��|
dk�s�|j'�r�t&}
d|_'|}|jdk�r�d}|j)�rB|�rt*|d��r||_||_!t+|j)||�}|j'�r�|}d}q�n`|�r�t*|d��r\|j}nd}|�r~t,j-j.d ||jf�nt,j-j.d!|j�nt,j-j.d"�dSnt&}
t|�dk�r�|jdk�r�d}d}d}|dd�=q�|jdk�r�dS|jdk�r�|d.}|jdk�r6|�r0t|d|j�|_t|d#|j�|_d}q�t�}d|_t*|d��r\|j|_|_t*|d#��rv|j|_|_||_|j|�|}q�|j�}|�r�|j|_|j|_|j�|d/}q�t/d$��q�WdS)0NrzPLY: PARSE DEBUG STARTrc)�lexz$end�zState  : %sz#Defaulted state %s: Reduce using %dzStack  : %sz%s . %s� cSsg|]
}|j�qSr	)r )r?�xxr	r	r
r@�sz'LRParser.parsedebug.<locals>.<listcomp>z Action : Shift and goto state %sz3Action : Reduce rule [%s] with %s and goto state %d�[�,cSsg|]}t|j��qSr	)r'r>)r?Z_vr	r	r
r@�s�]rMrQzResult : %srFr>zDone   : Returning %szPLY: PARSE DEBUG ENDzError  : %scSsg|]
}|j�qSr	)r )r?ryr	r	r
r@Bsr<rJz(yacc: Syntax error at line %d, token=%s
zyacc: Syntax error, token=%sz yacc: Parse error in input. EOF
rPzyacc: internal parser error!!!
���r}r}r}r}r}r}r}r}r}r})0rZr\rXrdr9rrwrvr<r3rrr0r_r`r;rar5r r�pop�get�joinr7�lstriprrr>rJrPrKrMrQr:rh�callabler%rU�extend�error_countr^rr2�hasattrr4rmrnr
�RuntimeError) rrrr<rrsrt�	lookahead�lookaheadstackrir\�prodrd�pslice�
errorcountrv�	get_tokenr_r`�errtokenrbrh�ltype�t�p�pname�plen�targ�t1rBr$�tokrJr	r	r
ro\s~





.






$








.


zLRParser.parsedebugc Csvd}g}|j}|j}	|j}
|j}td�}d}
|sBddlm}|j}||_||_|dk	r`|j	|�|dkrp|j
}n|}||_
g}||_g}||_||_
d}|jd�t�}d|_|j|�d}�x�||k�r|s�|s�|�}n|j�}|s�t�}d|_|j}||j|�}n||}|dk	�rh|dk�rN|j|�|}|j|�d}|
r�|
d8}
q�|dk�rF|
|}|j}|j}t�}||_d|_|�r�||dd�}||d<|�r�|d}|j|_|j|_|d}t|d|j�|_t|d|j�|_||_yP||d�=||_|j|�||d�=|j|�|	|d|}|j|�Wq�tk
�r�|j|�|j|dd��|j�|d}d|_d|_|}t }
d|_!Yq�Xq�n�|�r�|j|_|j|_|g}||_y8||_|j|�|j|�|	|d|}|j|�Wq�tk
�rB|j|�|j�|d}d|_d|_|}t }
d|_!Yq�Xq�|dk�rh|d}t|d	d�}|S|dk�rf|
dk�s�|j!�rNt }
d|_!|}|jdk�r�d}|j"�r�|�r�t#|d
��r�||_||_t$|j"||�}|j!�rL|}d}q�n`|�r<t#|d��r|j}nd}|�r(t%j&j'd||jf�nt%j&j'd
|j�nt%j&j'd�dSnt }
t|�dk�r�|jdk�r�d}d}d}|dd�=q�|jdk�r�dS|jdk�r6|d}|jdk�r�|�r�t|d|j�|_t|d|j�|_d}q�t�}d|_t#|d��r|j|_|_t#|d��r |j|_|_||_|j|�|}q�|j�}|�rT|j|_|j|_|j�|d}q�t(d��q�WdS)Nrrc)rvz$endrMrQrFr>r<rJz(yacc: Syntax error at line %d, token=%s
zyacc: Syntax error, token=%sz yacc: Parse error in input. EOF
rPzyacc: internal parser error!!!
r}r}r}r}r}r}r}r}r}))rZr\rXrdr9rwrvr<r3rrr0r_r`r;rar5r r~rrrr>rJrPrKrMrQr:rhr�rUr�r�r^r2r�r4rmrnr
r�) rrrr<rrsrtr�r�rir\r�rdr�r�rvr�r_r`r�rbrhr�r�r�r�r�r�r�rBr$r�rJr	r	r
rp�sX




















zLRParser.parseoptcCs�d}g}|j}|j}	|j}
|j}td�}d}
|sBddlm}|j}||_||_|dk	r`|j	|�|dkrp|j
}n|}||_
g}||_g}||_||_
d}|jd�t�}d|_|j|�d}�x||k�r|s�|s�|�}n|j�}|s�t�}d|_|j}||j|�}n||}|dk	�r|dk�rN|j|�|}|j|�d}|
r�|
d8}
q�|dk�r�|
|}|j}|j}t�}||_d|_|�rX||dd�}||d<||_yP||d�=||_|j|�||d�=|j|�|	|d|}|j|�Wq�tk
�rR|j|�|j|dd��|j�|d}d|_d|_|}t}
d|_Yq�Xq�n�|g}||_y8||_|j|�|j|�|	|d|}|j|�Wq�tk
�r�|j|�|j�|d}d|_d|_|}t}
d|_Yq�Xq�|dk�r|d}t|dd�}|S|dk�r�|
dk�s(|j�r�t}
d|_|}|jdk�rFd}|j�r�|�rht|d��rh||_||_t |j||�}|j�r�|}d}q�n`|�r�t|d	��r�|j!}nd}|�r�t"j#j$d
||jf�nt"j#j$d|j�nt"j#j$d�dSnt}
t|�dk�r(|jdk�r(d}d}d}|dd�=q�|jdk�r8dS|jdk�r�|d}|jdk�r^d}q�t�}d|_t|d	��r�|j!|_!|_%t|d
��r�|j&|_&|_'||_|j|�|}q�|j�}|j�|d}q�t(d��q�WdS)Nrrc)rvz$endrFr>r<rJz(yacc: Syntax error at line %d, token=%s
zyacc: Syntax error, token=%sz yacc: Parse error in input. EOF
rPzyacc: internal parser error!!!
r}r}r}r}r}r}r}r}))rZr\rXrdr9rwrvr<r3rrr0r_r`r;rar5r r~rrrr>r:rhr�rUr�r�r^rKr2r�r4rJrmrnr
rMrPrQr�)rrrr<rrsrtr�r�rir\r�rdr�r�rvr�r_r`r�rbrhr�r�r�r�r�r�rBr$r�rJr	r	r
rq�s8




















zLRParser.parseopt_notrack)NNFFN)NNFFN)NNFFN)NNFFN)rrrrr,r.r]rjrurorprqr	r	r	r
rVs

]
4rVz^[a-zA-Z0-9_-]+$c@sReZdZdZddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�ZdS)�
Productionr�rightNrwc	Cs�||_t|�|_||_||_d|_||_||_||_t	|j�|_	g|_
x$|jD]}||j
krN|j
j|�qNWg|_d|_
|jr�d|jdj|j�f|_nd|j|_dS)Nz%s -> %srxz
%s -> <empty>)r�tupler��number�funcr��file�line�precr�usymsra�lr_items�lr_nextr�r7)	rr�rr��
precedencer�r�r�r=r	r	r
rs$

zProduction.__init__cCs|jS)N)r7)rr	r	r
r6=szProduction.__str__cCsdt|�dS)NzProduction(�))r7)rr	r	r
r8@szProduction.__repr__cCs
t|j�S)N)rr�)rr	r	r
rICszProduction.__len__cCsdS)Nrcr	)rr	r	r
�__nonzero__FszProduction.__nonzero__cCs
|j|S)N)r�)r�indexr	r	r
rCIszProduction.__getitem__cCs�|t|j�krdSt||�}yt|j|d|_Wnttfk
rRg|_YnXy|j|d|_Wntk
r�d|_YnX|S)Nrc)rr��LRItem�	Prodnames�lr_after�
IndexError�KeyError�	lr_before)rrBr�r	r	r
�lr_itemMs
zProduction.lr_itemcCs|jr||j|_dS)N)r�r�)r�pdictr	r	r
�bind]szProduction.bind�r�r)r�Nrwr)rrr�reducedrr6r8rIr�rCr�r�r	r	r	r
r�s
r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�MiniProductioncCs.||_||_||_d|_||_||_||_dS)N)rrr�r�r�r�r7)rr7rrr�r�r�r	r	r
rfszMiniProduction.__init__cCs|jS)N)r7)rr	r	r
r6oszMiniProduction.__str__cCs
d|jS)NzMiniProduction(%s))r7)rr	r	r
r8rszMiniProduction.__repr__cCs|jr||j|_dS)N)r�r�)rr�r	r	r
r�vszMiniProduction.bindN)rrrrr6r8r�r	r	r	r
r�es	r�c@s$eZdZdd�Zdd�Zdd�ZdS)r�cCsZ|j|_t|j�|_|j|_||_i|_|jj|d�t|j�|_t|j�|_|j	|_	dS)N�.)
rrfr�r��lr_index�
lookaheads�insertr�rr�)rr�rBr	r	r
r�szLRItem.__init__cCs,|jrd|jdj|j�f}n
d|j}|S)Nz%s -> %srxz
%s -> <empty>)r�rr�)rr=r	r	r
r6�s
zLRItem.__str__cCsdt|�dS)NzLRItem(r�)r7)rr	r	r
r8�szLRItem.__repr__N)rrrrr6r8r	r	r	r
r��sr�cCs:t|�d}x(|dkr4|||kr*||S|d8}qWdS)Nrcr)r)Zsymbols�	terminalsrFr	r	r
�rightmost_terminal�s
r�c@seZdZdS)�GrammarErrorN)rrrr	r	r	r
r��sr�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd$dd
�Zd%dd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd&d d!�Zd"d#�Zd	S)'�GrammarcCsfdg|_i|_i|_i|_x|D]}g|j|<q Wg|jd<i|_i|_i|_i|_t�|_	d|_
dS)Nr)�Productionsr��Prodmap�	Terminals�Nonterminals�First�Follow�
Precedence�set�UsedPrecedence�Start)rr��termr	r	r
r�s

zGrammar.__init__cCs
t|j�S)N)rr�)rr	r	r
rI�szGrammar.__len__cCs
|j|S)N)r�)rr�r	r	r
rC�szGrammar.__getitem__cCsL|jdgkstd��||jkr*td|��|dkr:td��||f|j|<dS)Nz2Must call set_precedence() before add_production()z,Precedence already specified for terminal %r�leftr��nonassocz:Associativity must be one of 'left','right', or 'nonassoc')r�r�r�)r��AssertionErrorr�r�)rr��assoc�levelr	r	r
�set_precedence�s
zGrammar.set_precedenceNrwrcCs�||jkrtd|||f��|dkr6td|||f��tj|�sRtd|||f��x�t|�D]�\}}|ddkr�yJt|�}t|�dkr�td||||f��||jkr�g|j|<|||<w\Wntk
r�YnXtj|�r\|d	kr\td
||||f��q\Wd	|k�r�|dd	k�r$td||f��|dd	k�rBtd
||f��|d}	|jj	|	�}
|
�sptd|||	f��n|j
j|	�|dd�=nt||j�}	|jj	|	d�}
d||f}||j
k�r�|j
|}td|||fd|j|jf��t|j�}
||jk�rg|j|<xR|D]J}||jk�r.|j|j|
�n&||jk�rDg|j|<|j|j|
��qWt|
|||
|||�}|jj|�||j
|<y|j|j|�Wn"tk
�r�|g|j|<YnXdS)Nz7%s:%d: Illegal rule name %r. Already defined as a tokenrz5%s:%d: Illegal rule name %r. error is a reserved wordz%s:%d: Illegal rule name %rrz'"rczA%s:%d: Literal token %s in rule %r may only be a single characterz%precz!%s:%d: Illegal name %r in rule %rz+%s:%d: Syntax error. Nothing follows %%prec�zH%s:%d: Syntax error. %%prec can only appear at the end of a grammar rulez/%s:%d: Nothing known about the precedence of %rr�z%s -> %sz%s:%d: Duplicate rule %s. zPrevious definition at %s:%dr}���r}r�)r�r)r�r��_is_identifier�match�	enumerate�evalrrUr�rr��addr�r�r�r�r�r�rar�r�r�)r�prodname�symsr�r�r�rBr=�cZprecnameZprodprec�map�mZpnumberr�r�r	r	r
�add_production
sp










zGrammar.add_productioncCsT|s|jdj}||jkr&td|��tdd|g�|jd<|j|jd�||_dS)Nrczstart symbol %s undefinedrzS')r�rr�r�r�rar�)r�startr	r	r
�	set_startas
zGrammar.set_startcs>���fdd��t����jdjd��fdd��jD�S)NcsJ|�krdS�j|�x.�jj|g�D]}x|jD]}�|�q2Wq&WdS)N)r�r�rr�)r=r�r")�mark_reachable_from�	reachablerr	r
r�ts
z5Grammar.find_unreachable.<locals>.mark_reachable_fromrcsg|]}|�kr|�qSr	r	)r?r=)r�r	r
r@~sz,Grammar.find_unreachable.<locals>.<listcomp>)r�r�r�r�)rr	)r�r�rr
�find_unreachableqszGrammar.find_unreachablecCs�i}x|jD]}d||<qWd|d<x|jD]}d||<q,Wxpd}x`|jj�D]R\}}xH|D]@}x |jD]}||shd}PqhWd}|r\||s�d||<d}Pq\WqNW|s>Pq>Wg}	x@|j�D]4\}}
|
s�||jkr�||jkr�|dkr�q�|	j|�q�W|	S)NTz$endFr)r�r�r�rer�ra)rZ
terminatesr�rB�some_changeZplr�r=Zp_terminates�infiniter�r	r	r
�infinite_cycles�s:

zGrammar.infinite_cyclescCsXg}xN|jD]D}|sqx8|jD].}||jkr||jkr|dkr|j||f�qWqW|S)Nr)r�r�r�r�ra)rr$r�r=r	r	r
�undefined_symbols�szGrammar.undefined_symbolscCs8g}x.|jj�D] \}}|dkr|r|j|�qW|S)Nr)r�rera)rZ
unused_tokr=rDr	r	r
�unused_terminals�s
zGrammar.unused_terminalscCs<g}x2|jj�D]$\}}|s|j|d}|j|�qW|S)Nr)r�rer�ra)rZunused_prodr=rDr�r	r	r
�unused_rules�szGrammar.unused_rulescCsDg}x:|jD]0}||jkp"||jks|j||j|df�qW|S)Nr)r�r�r�ra)rZunusedZtermnamer	r	r
�unused_precedence�s
zGrammar.unused_precedencecCs`g}xV|D]D}d}x2|j|D]$}|dkr0d}q||kr|j|�qW|rLq
Pq
W|jd�|S)NFz<empty>T)r�ra)rZbetar$�xZx_produces_emptyrr	r	r
�_first	s

zGrammar._firstcCs�|jr|jSx|jD]}|g|j|<qWdg|jd<x|jD]}g|j|<q<Wxjd}xZ|jD]P}xJ|j|D]<}x6|j|j�D]&}||j|kr~|j|j|�d}q~WqlWq\W|sPPqPW|jS)Nz$endFT)r�r�r�r�r�r�ra)rr�rBr�r�rr	r	r
�
compute_first,s$zGrammar.compute_firstc
CsV|jr|jS|js|j�x|jD]}g|j|<q"W|sD|jdj}dg|j|<�x�d}x�|jdd�D]�}x�t|j�D]�\}}||jkrx|j|j|dd��}d}xB|D]:}	|	dkr�|	|j|kr�|j|j	|	�d}|	dkr�d}q�W|�s|t
|j�dkrxx:|j|jD]*}	|	|j|k�r|j|j	|	�d}�qWqxWqhW|sTPqTW|jS)Nrcz$endFz<empty>T)r�r�r�r�r�rr�r�r�rar)
rr��k�didaddr�rF�BZfstZhasemptyrr	r	r
�compute_followQs<

zGrammar.compute_followcCs�x�|jD]�}|}d}g}x�|t|�kr,d}ntt||�}y|j|j|d|_Wnttfk
rng|_YnXy|j|d|_Wntk
r�d|_YnX||_	|s�P|j
|�|}|d7}qW||_qWdS)Nrrc)r�rr�r�r�r�r�r�r�r�rar�)rr�ZlastlrirFr�Zlrir	r	r
�
build_lritems�s.

zGrammar.build_lritems)Nrwr)N)N)rrrrrIrCr�r�r�r�r�r�r�r�r�r�r�r�r�r	r	r	r
r��s $
T
@#%
;r�c@seZdZdS)�VersionErrorN)rrrr	r	r	r
r��sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�LRTablecCsd|_d|_d|_d|_dS)N)rYr[rW�	lr_method)rr	r	r
r�szLRTable.__init__cCs~t|tj�r|}ntd|�tj|}|jtkr:td��|j	|_
|j|_g|_
x|jD]}|j
jt|��qXW|j|_|jS)Nz	import %sz&yacc table file version is out of date)rA�types�
ModuleType�execrm�modulesZ_tabversion�__tabversion__r�Z
_lr_actionrYZ_lr_gotor[rWZ_lr_productionsrar�Z
_lr_methodr�Z
_lr_signature)r�modulerr�r	r	r
�
read_table�s

zLRTable.read_tablecCs�yddl}Wntk
r(ddl}YnXtjj|�s:t�t|d�}|j|�}|tkr^t	d��|j|�|_
|j|�}|j|�|_|j|�|_|j|�}g|_
x|D]}|j
jt|��q�W|j�|S)Nr�rbz&yacc table file version is out of date)�cPickle�ImportError�pickle�os�path�exists�open�loadr�r�r�rYr[rWrar��close)r�filenamer�Zin_fZ
tabversion�	signaturerXr�r	r	r
�read_pickle�s(




zLRTable.read_picklecCsx|jD]}|j|�qWdS)N)rWr�)rr�r�r	r	r
�bind_callables�szLRTable.bind_callablesN)rrrrr�rrr	r	r	r
r��sr�c	CsTi}x|D]}d||<q
Wg}i}x,|D]$}||dkr(t|||||||�q(W|S)Nr)�traverse)�X�R�FP�Nr�r;�Fr	r	r
�digraphs

r	c	Cs|j|�t|�}|||<||�||<||�}xr|D]j}	||	dkrXt|	||||||�t||||	�||<x.|j|	g�D]}
|
||kr|||j|
�q|Wq4W|||k�rt||d<||||d<|j�}x2||k�rt||d<||||d<|j�}q�WdS)Nrrcr}r}r}r})rarr�minr�MAXINTr~)r�rr;rrrr�d�rel�y�a�elementr	r	r
rs(

rc@seZdZdS)�	LALRErrorN)rrrr	r	r	r
r)src@s�eZdZd$dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd%d d!�Zd&d"d#�ZdS)'�LRGeneratedTablerNcCs�|dkrtd|��||_||_|s*t�}||_i|_i|_|j|_i|_	i|_
d|_d|_d|_
g|_g|_g|_|jj�|jj�|jj�|j�dS)N�SLRrzUnsupported method %sr)rr)r�grammarr�r�logrYr[r�rW�
lr_goto_cache�lr0_cidhash�
_add_countZsr_conflictZrr_conflictZ	conflicts�sr_conflicts�rr_conflictsr�r�r��lr_parse_table)rr�methodrr	r	r
r4s,


zLRGeneratedTable.__init__cCsz|jd7_|dd�}d}xV|rtd}xH|D]@}x:|jD]0}t|dd�|jkrRq:|j|j�|j|_d}q:Wq.Wq W|S)NrcTF�	lr0_addedr)rr�rKrar�r)r�I�Jr�rGr�r	r	r
�lr0_closureYs
zLRGeneratedTable.lr0_closurec	Cs�|jjt|�|f�}|r|S|jj|�}|s:i}||j|<g}xP|D]H}|j}|rD|j|krD|jt|��}|s~i}||t|�<|j|�|}qDW|jd�}|s�|r�|j|�}||d<n||d<||jt|�|f<|S)Nz$end)rrr!r�r�rar )	rrr��gr=Zgsr�rB�s1r	r	r
�lr0_gotoss2





zLRGeneratedTable.lr0_gotoc	Cs�|j|jjdjg�g}d}x"|D]}||jt|�<|d7}q"Wd}x�|t|�kr�||}|d7}i}x$|D]}x|jD]}d||<qxWqlWxJ|D]B}|j||�}|s�t|�|jkr�q�t|�|jt|�<|j	|�q�WqFW|S)Nrrc)
r rr�r�rr!rr�r#ra)	r�CrFrZasyms�iir=r�r!r	r	r
�	lr0_items�s(


zLRGeneratedTable.lr0_itemscCs�t�}d}xrxV|jjdd�D]B}|jdkr:|j|j�qx$|jD]}||krBPqBW|j|j�qWt|�|krrPt|�}qW|S)Nrrc)r�rr�rr�rr�)r�nullableZnum_nullabler�r�r	r	r
�compute_nullable_nonterminals�s
z.LRGeneratedTable.compute_nullable_nonterminalscCsrg}xht|�D]\\}}xR|D]J}|j|jdkr||j|jdf}|d|jjkr||kr|j|�qWqW|S)Nrc)r�r�rr�rr�ra)rr$�transZstatenorhr�r�r	r	r
�find_nonterminal_transitions�s
z-LRGeneratedTable.find_nonterminal_transitionscCs�i}|\}}g}|j|||�}xJ|D]B}	|	j|	jdkr&|	j|	jd}
|
|jjkr&|
|kr&|j|
�q&W|dkr�||jjdjdkr�|jd�|S)Nrcrz$end)r#r�rr�rr�rar�)rr$r)r'Zdr_setrhr�termsr!r�rr	r	r
�dr_relation�s

zLRGeneratedTable.dr_relationcCsvg}|\}}|j|||�}|jjt|�d�}xB|D]:}	|	j|	jdkr4|	j|	jd}
|
|kr4|j||
f�q4W|S)Nrcr})r#rrr!r�rr�ra)rr$r)�emptyr
rhrr!rGr�rr	r	r
�reads_relation	s
zLRGeneratedTable.reads_relationcCs�i}i}i}x|D]}d||<qW�x�|D�]�\}}	g}
g}�xR||D�]D}|j|	krZqH|j}
|}x�|
|jdk�r
|
d}
|j|
}||f|kr�|
d}xH||jkr�|j||jjkr�P|j||kr�P|d}q�W|j||f�|j|||�}|jj	t
|�d�}qfWx�||D]t}|j|jk�r,�q|j|jk�r>�qd}xD||jk�rx|j||j|dk�rlP|d}�qDW|
j||f��qWqHWx2|D]*}||k�r�g||<||j||	f��q�W|
|||	f<q*W||fS)Nrcrr})rr�rr�rr�rar#rrr!)rr$r)r'ZlookdictZincludedictZdtransr�rhrZlookbZincludesr�r�rGZlir!r"rFr	r	r
�compute_lookback_includesC	sX




z*LRGeneratedTable.compute_lookback_includescs0���fdd�}���fdd�}t|||�}|S)Ncs�j�|��S)N)r,)r�)r$r'rr	r
�<lambda>�	sz4LRGeneratedTable.compute_read_sets.<locals>.<lambda>cs�j�|��S)N)r.)r�)r$r'rr	r
r0�	s)r	)rr$�ntransr'rrrr	)r$r'rr
�compute_read_sets�	sz"LRGeneratedTable.compute_read_setscs(�fdd�}�fdd�}t|||�}|S)Ncs�|S)Nr	)r�)�readsetsr	r
r0�	sz6LRGeneratedTable.compute_follow_sets.<locals>.<lambda>cs�j|g�S)N)r)r�)�inclsetsr	r
r0�	s)r	)rr1r3r4rrrr	)r4r3r
�compute_follow_sets�	sz$LRGeneratedTable.compute_follow_setsc	Csxxr|j�D]f\}}x\|D]T\}}||jkr4g|j|<|j|g�}x*|D]"}||j|krF|j|j|�qFWqWq
WdS)N)rer�rra)	rZ	lookbacksZ	followsetr)Zlbrhr�rrr	r	r
�add_lookaheads�	s


zLRGeneratedTable.add_lookaheadscCsP|j�}|j|�}|j|||�}|j|||�\}}|j|||�}|j||�dS)N)r(r*r2r/r5r6)rr$r'r)r3ZlookdZincludedZ
followsetsr	r	r
�add_lalr_lookaheads�	s
z$LRGeneratedTable.add_lalr_lookaheadsc$	Cs<|jj}|jj}|j}|j}|j}i}|jd|j�|j�}|jdkrP|j	|�d}�x�|D�]�}	g}
i}i}i}
|jd�|jd|�|jd�x|	D]}|jd|j
|�q�W|jd��x|	D�]�}|j|jdk�r,|j
dkr�d|d	<||d	<�q�|jdk�r|j|}n|jj|j
}�x�|D�]�}|
j||d
|j
|ff�|j|�}|dk	�r�|dk�rB|||j
j\}}|j|d�\}}||k�s�||k�r�|dk�r�|j
||<|||<|�r�|�r�|jd
|�|jj||df�||j
jd7_nB||k�r|dk�rd||<n$|�s�|jd|�|jj||df�n�|dk�r�||}||j
}|j|jk�r�|j
||<|||<||}}||j
jd7_||j
jd8_n
||}}|jj|||f�|jd|||j
||�ntd|��n(|j
||<|||<||j
jd7_�q&Wq�|j}|j|d}||jjkr�|j|	|�}|jjt|�d�}|dkr�|
j||d|f�|j|�}|dk	�r�|dk�r�||k�r�td|��n�|dk�r�|||j
j\}}|j|d�\}}||k�s||k�rV|dk�rV|||j
jd8_|||<|||<|�s�|jd|�|jj||df�nL||k�rt|dk�rtd||<n.|�r�|�r�|jd
|�|jj||df�ntd|��q�|||<|||<q�Wi}xF|
D]>\}}}||k�r�|||k�r�|jd||�d|||f<�q�W|jd�d}xX|
D]P\}}}||k�r&|||k	�r&||f|k�r&|jd||�d}d|||f<�q&W|�r�|jd�i} x6|	D].}!x&|!jD]}"|"|jjk�r�d| |"<�q�W�q�WxL| D]D}#|j|	|#�}|jjt|�d�}|dk�r�||
|#<|jd|#|��q�W|||<|||<|
||<|d7}q\WdS)NzParsing method: %srrrwzstate %dz    (%d) %srczS'z$endzreduce using rule %d (%s)r�r�z3  ! shift/reduce conflict for %s resolved as reduce�reducer�z2  ! shift/reduce conflict for %s resolved as shiftZshiftz=  ! reduce/reduce conflict for %s resolved using rule %d (%s)zUnknown conflict in state %dzshift and go to state %dz Shift/shift conflict in state %dz    %-15s %sz  ! %-15s [ %s ]z"    %-30s shift and go to state %d)r�rr})r�rr}) rr�r�r[rYrrr�r&r7r�rr�rr�r�rarr�rr�r�rrr�r�r#rr!rr�r�)$rr�r�r\rZrZactionpr$�strZactlistZ	st_actionZ
st_actionpZst_gotor�Zlaheadsrr"ZsprecZslevelZrprecZrlevelZoldpZppZchosenpZrejectprFr!rGZ	_actprintr�Znot_usedZnkeysr%r=rBr	r	r
r�	s




























zLRGeneratedTable.lr_parse_tablerwcCs�t|tj�rtd��|jd�d}tjj||�d}�ylt|d�}|j	dtjj
|�t|j|f�d}|�rti}xf|j
j�D]X\}	}
xN|
j�D]B\}}|j|�}
|
s�ggf}
|
||<|
dj|	�|
dj|�q�Wq|W|j	d�xz|j�D]n\}}|j	d	|�x |dD]}
|j	d
|
��qW|j	d�x |dD]}
|j	d
|
��q8W|j	d�q�W|j	d
�|j	d�nJ|j	d�x4|j
j�D]&\}}|j	d|d|d|f��q�W|j	d
�|�r�i}xl|jj�D]^\}	}
xR|
j�D]F\}}|j|�}
|
�sggf}
|
||<|
dj|	�|
dj|��q�W�q�W|j	d�x||j�D]p\}}|j	d	|�x |dD]}
|j	d
|
��qjW|j	d�x |dD]}
|j	d
|
��q�W|j	d��qJW|j	d
�|j	d�nJ|j	d�x4|jj�D]&\}}|j	d|d|d|f��q�W|j	d
�|j	d�xd|jD]Z}|j�rl|j	d|j|j|j|jtjj
|j�|jf�n|j	dt|�|j|jf��q0W|j	d�|j�Wn&tk
�r�}z�WYdd}~XnXdS)Nz"Won't overwrite existing tabmoduler�rcz.py�wzu
# %s
# This file is automatically generated. Do not edit.
_tabversion = %r

_lr_method = %r

_lr_signature = %r
    rz
_lr_action_items = {z%r:([z%r,z],[z]),z}
z�
_lr_action = {}
for _k, _v in _lr_action_items.items():
   for _x,_y in zip(_v[0],_v[1]):
      if not _x in _lr_action:  _lr_action[_x] = {}
      _lr_action[_x][_k] = _y
del _lr_action_items
z
_lr_action = { z(%r,%r):%r,z
_lr_goto_items = {z�
_lr_goto = {}
for _k, _v in _lr_goto_items.items():
   for _x, _y in zip(_v[0], _v[1]):
       if not _x in _lr_goto: _lr_goto[_x] = {}
       _lr_goto[_x][_k] = _y
del _lr_goto_items
z
_lr_goto = { z_lr_productions = [
z  (%r,%r,%d,%r,%r,%d),
z  (%r,%r,%d,None,None,None),
z]
r})rAr�r��IOError�splitr�r�r�r�r
�basenamer�r�rYrerrar[rWr�r7rrr�r�r�)r�	tabmodule�	outputdirrZbasemodulenamer�rZsmallerrer=ZndrrDrFr�r��er	r	r
�write_table�
s�





"





"

"
zLRGeneratedTable.write_tablecCsyddl}Wntk
r(ddl}YnXt|d���}|jt|t�|j|j|t�|j||t�|j|j|t�|j|j	|t�g}x^|j
D]T}|jr�|j|j
|j|j|jtjj|j�|jf�q�|jt
|�|j|jdddf�q�W|j||t�WdQRXdS)Nr�wb)r�r�r�r��dumpr��pickle_protocolr�rYr[rWr�rar7rrr�r�r=r�r�)rr�rr�ZoutfZoutpr�r	r	r
�pickle_tables ,"zLRGeneratedTable.pickle_table)rN)rwrw)rw)rrrrr r#r&r(r*r,r.r/r2r5r6r7rrArEr	r	r	r
r3s"
%#8+P8
zrcCs0tj|�}|jj�}|j|jkr,|j|j�|S)N)rm�	_getframe�	f_globals�copy�f_locals�update)ZlevelsrZldictr	r	r
�get_caller_module_dict9s


rKcCsg}|j�}d}|}x�|D]�}|d7}|j�}|s4qy�|ddkrh|sVtd||f��|}	|dd�}
n@|d}	|	}|dd�}
|d}|dkr�|dkr�td||f��|j|||	|
f�Wqtk
r��Yqtk
r�td	|||j�f��YqXqW|S)
Nrcr�|z%s:%d: Misplaced '|'r��:z::=z!%s:%d: Syntax error. Expected ':'z%s:%d: Syntax error in rule %r)�
splitlinesr<rUra�	Exception�strip)�docr�r�rZpstringsZlastpZdlineZpsr�r�r�Zassignr	r	r
�
parse_grammarEs6
 rRc@s�eZdZd dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)!�
ParserReflectNcCsL||_d|_d|_d|_t�|_g|_d|_|dkrBtt	j
�|_n||_dS)NF)r�r��
error_func�tokensr�r�rrrrmrnr)rr�rr	r	r
roszParserReflect.__init__cCs,|j�|j�|j�|j�|j�dS)N)�	get_start�get_error_func�
get_tokens�get_precedence�get_pfunctions)rr	r	r
�get_all~s
zParserReflect.get_allcCs6|j�|j�|j�|j�|j�|j�|jS)N)�validate_start�validate_error_func�validate_tokens�validate_precedence�validate_pfunctions�validate_modulesr)rr	r	r
�validate_all�szParserReflect.validate_allcCsyddlm}Wn tk
r0ddlm}YnXy�|dd�}|jrV|j|jjd��|jr~|jdjdd�|jD��jd��|jr�|jd	j|j�jd��x*|j	D] }|d
r�|j|d
jd��q�WWnt
tfk
r�YnXtj
|j��}tjdd
k�r|jd�}|S)Nr)�md5F)Zusedforsecurityzlatin-1rwcSsg|]}dj|��qS)rw)r�)r?r�r	r	r
r@�sz+ParserReflect.signature.<locals>.<listcomp>rxr)Zhashlibrcr�r�rJ�encoder�r�rU�pfuncs�	TypeError�
ValueError�base64Z	b16encode�digestrm�version_info�decode)rrcZsigrrir	r	r
r�s*
"
zParserReflect.signaturecCs�tjd�}x�|jD]�}ytj|�\}}Wntk
r>wYnXi}xjt|�D]^\}}|d7}|j|�}|rN|jd�}|j	|�}	|	s�|||<qNtj
|�}
|jjd|
|||	�qNWqWdS)Nz\s*def\s+(p_[a-zA-Z_0-9]*)\(rcz;%s:%d: Function %s redefined. Previously defined on line %d)
�re�compiler��inspectZgetsourcelinesr;r�r��groupr�
getsourcefilerr)rZfrer��linesZlinenZ	counthashr�r�r�prevr�r	r	r
ra�s$





zParserReflect.validate_modulescCs|jjd�|_dS)Nr�)r�rr�)rr	r	r
rV�szParserReflect.get_startcCs&|jdk	r"t|jt�s"|jjd�dS)Nz'start' must be a string)r�rA�string_typesrr)rr	r	r
r\�s
zParserReflect.validate_startcCs|jjd�|_dS)N�p_error)r�rrT)rr	r	r
rW�szParserReflect.get_error_funccCs�|jr�t|jtj�rd}n*t|jtj�r.d}n|jjd�d|_dS|jjj}|jjj	}t
j|j�}|jj
|�|jjj|}|dkr�|jjd||�d|_dS)Nrrcz2'p_error' defined, but is not a function or methodTz$%s:%d: p_error() requires 1 argument)rTrAr��FunctionType�
MethodTyperr�__code__�co_firstlineno�co_filenamern�	getmoduler�r��co_argcount)rZismethodZelineZefiler�Zargcountr	r	r
r]�s 

z!ParserReflect.validate_error_funccCsn|jjd�}|s&|jjd�d|_dSt|ttf�sJ|jjd�d|_dS|sd|jjd�d|_dS||_dS)NrUzNo token list is definedTztokens must be a list or tupleztokens is empty)r�rrrrArfr�rU)rrUr	r	r
rX�szParserReflect.get_tokenscCsZd|jkr |jjd�d|_dSt�}x.|jD]$}||krH|jjd|�|j|�q.WdS)Nrz.Illegal token name 'error'. Is a reserved wordTzToken %r multiply defined)rUrrr�rr�)rr�rBr	r	r
r^s
zParserReflect.validate_tokenscCs|jjd�|_dS)Nr�)r�rr�)rr	r	r
rYszParserReflect.get_precedencecCsg}|j�rt|jttf�s2|jjd�d|_dSx�t|j�D]�\}}t|ttf�sj|jjd�d|_dSt|�dkr�|jjd|�d|_dS|d}t|t�s�|jjd�d|_dSxH|dd�D]8}t|t�s�|jjd	�d|_dS|j	|||df�q�Wq>W||_
dS)
Nz"precedence must be a list or tupleTzBad precedence tabler�z?Malformed precedence entry %s. Must be (assoc, term, ..., term)rz)precedence associativity must be a stringrcz precedence items must be strings)r�rArfr�rrr�rrsra�preclist)rr|r�r�r�r�r	r	r
r_s6

z!ParserReflect.validate_precedencecCs�g}xl|jj�D]^\}}|jd�s|dkr.qt|tjtjf�rt|d|jj	�}t
j|�}|j||||j
f�qW|jdd�d�||_dS)N�p_rtrxcSs |dt|d�|d|dfS)Nrrcr�r)r7)Z
p_functionr	r	r
r0Bs
z.ParserReflect.get_pfunctions.<locals>.<lambda>)�key)r�re�
startswithrAr�rurvrKrwrxrnrzra�__doc__�sortre)rZp_functionsr�itemr�r�r	r	r
rZ5s
zParserReflect.get_pfunctionscCs^g}t|j�dkr(|jjd�d|_dS�x"|jD�]\}}}}tj|�}|j|}t|tj	�rfd}nd}|j
j|kr�|jjd|||j�d|_q2|j
j|kr�|jjd|||j�d|_q2|j
s�|jjd|||j�q2y,t|||�}	x|	D]}
|j||
f�q�WWn:tk
�r<}z|jjt|��d|_WYdd}~XnX|jj|�q2W�x|jj�D]�\}}
|jd	��r�t|
tjtj	f��r��q\|jd
��r��q\|jd	��r�|dk�r�|jjd|�t|
tj��r�|
j
jdk�s�t|
tj	��r\|
jj
jdk�r\|
j
�r\y8|
j
jd
�}|ddk�r4|jjd|
j
j|
j
j|�Wntk
�rLYnX�q\W||_dS)Nrz+no rules of the form p_rulename are definedTr�rcz%%s:%d: Rule %r has too many argumentsz#%s:%d: Rule %r requires an argumentzA%s:%d: No documentation string specified in function %r (ignored)r}Zt_rtz%r not defined as a functionrxrMz9%s:%d: Possible grammar rule %r defined without p_ prefix)rrerrrnrpr�rAr�rvrwr{rr�rrRrarUr7r�r�rerru�__func__r<ryrxr�r)rrr�r�rrQr�r�ZreqargsZparsed_gr!r@rBrDr	r	r
r`Js\


 z!ParserReflect.validate_pfunctions)N)rrrrr[rbrrarVr\rWr]rXr^rYr_rZr`r	r	r	r
rSns

#rSc
<Osd	|dkrt}|rd}|dkr&ttj�}�rf�fdd�t��D�}
t|
�}d|krntj|dj|d<ntd�}|	dkr�t	|t
j�r�|j}nLd|kr�|d}n:|jd�}dj
|dd6��}td	|�ttj|dd
�}tjj|�}	|jd�}|o�t	|t��rd|k�r|d|}|dk	�r$||d<t||d
�}|j�|j�rHtd��|j�}y�t�}|�rj|j|�}n
|j|�}|�s�||k�r�y"|j|j�t||j �}|j!a!|St"k
�r�}z|j#d|�WYdd}~XnXWnFt$k
�r}z|j#t|��WYdd}~Xnt%k
�r YnX|
dk�r�|�r�ytt&tjj
|	|�d��}
Wn<t'k
�r�}z|j#d||f�t(�}
WYdd}~XnXnt(�}
|
j)dt*�d}|j+��r�td��|j �s�|j#d�t,|j-�}xZ|j.D]P\}}}y|j/|||�Wn0t0k
�r&}z|j#d|�WYdd}~XnX�q�Wxl|j1D]b\}}|\} }!}"}#y|j2|"|#|| |!�Wn4t0k
�r�}z|jd|�d}WYdd}~XnX�q6Wy&|dk�r�|j3|j4�n
|j3|�Wn6t0k
�r�}z|jt|��d}WYdd}~XnX|�rtd��|j5�}$x*|$D]"\}%}&|jd|&j6|&j7|%�d}�qW|j8�}'|'�r�|
j)d
�|
j)d�|
j)d
�x&|'D]}|j#d|�|
j)d|��qnW|�r�|
j)d
�|
j)d�|
j)d
�x&t9|j:�D]\}(})|
j)d|(|)��q�W|j;�}*x$|*D]}&|j#d|&j6|&j7|&j<��q�Wt=|'�dk�r"|j#d�t=|'�dk�r@|j#dt=|'��t=|*�dk�rX|j#d �t=|*�dk�rv|j#d!t=|*��|�rN|
j)d
�|
j)d"�|
j)d
�t>|j?�}+|+j@�x2|+D]*}|
j)d#|d$j
d%d�|j?|D����q�W|
j)d
�|
j)d&�|
j)d
�t>|jA�},|,j@�x2|,D]*}-|
j)d#|-d$j
d'd�|jA|-D����qW|
j)d
�|�r�|jB�}.x|.D]}/|j#d(|/��qbW|jC�}0x|0D]}1|jd)|1�d}�q�W|jD�}2x$|2D]\}}|jd*||�d}�q�W|�r�td��|�r�|jEd+|�tF|||
�}|�rlt=|jG�}3|3dk�r |j#d,�n|3dk�r6|j#d-|3�t=|jH�}4|4dk�rV|j#d.�n|4dk�rl|j#d/|4�|�r�|jG�s�|jH�r�|
j#d
�|
j#d0�|
j#d
�x&|jGD]\}5}6}7|
j#d1|6|5|7��q�WtI�}8x�|jHD]x\}5}9}:|5tJ|9�tJ|:�f|8k�r��q�|
j#d2|5|9�|
j#d3|:|5�|j#d2|5|9�|j#d3|:|5�|8jK|5tJ|9�tJ|:�f��q�Wg};xL|jHD]B\}5}9}:|:jL�r^|:|;k�r^|
j#d4|:�|j#d4|:�|;jM|:��q^W|�r�y|jN||	|�Wn6t'k
�r�}z|j#d5||f�WYdd}~XnX|�	rBy|jO||�Wn6t'k
�	r@}z|j#d5||f�WYdd}~XnX|j|j�t||j �}|j!a!|S)7Nrcsg|]}|t�|�f�qSr	)rK)r?r�)r�r	r
r@�szyacc.<locals>.<listcomp>�__file__rr�r�rcz	import %srw�__package__r�)rzUnable to build parserz.There was a problem loading the table file: %rr:zCouldn't open %r. %sz5Created by PLY version %s (http://www.dabeaz.com/ply)Fz no p_error() function is definedz%sTz;%s:%d: Symbol %r used, but not defined as a token or a rulezUnused terminals:zToken %r defined, but not usedz    %sr�zRule %-5d %sz$%s:%d: Rule %r defined, but not usedzThere is 1 unused tokenzThere are %d unused tokenszThere is 1 unused rulezThere are %d unused rulesz'Terminals, with rules where they appearz
%-20s : %srxcSsg|]}t|��qSr	)r7)r?r=r	r	r
r@E
sz*Nonterminals, with rules where they appearcSsg|]}t|��qSr	)r7)r?r=r	r	r
r@M
szSymbol %r is unreachablez)Infinite recursion detected for symbol %rz0Precedence rule %r defined for unknown symbol %rzGenerating %s tablesz1 shift/reduce conflictz%d shift/reduce conflictsz1 reduce/reduce conflictz%d reduce/reduce conflictsz
Conflicts:z7shift/reduce conflict for %s in state %d resolved as %sz;reduce/reduce conflict in state %d resolved using rule (%s)zrejected rule (%s) in state %dzRule (%s) is never reducedzCouldn't create %r. %sr})P�
tab_modulerrmrn�dir�dictr�r�rKrAr�r�r<r�r�rKr�r��dirnamerr7rSr[rrrr�rr�rr�rVrTrurOrr�r�r�r;rr�__version__rbr�rUr|r�r�rr�r�r�r�r�r�r�r�r�r�rrrfr�r�r�r�r�r�rrrrr�r!r�r�rarArE)<rrr�r>r�Zcheck_recursion�optimizeZwrite_tablesZ	debugfiler?ZdebuglogZerrorlogZ
picklefileZ_itemsr�Zsrcfile�partsZpkgnameZpkgZpinforZlrZread_signaturer3r@�errorsrr�r�r��funcnameZgramr�r�r�r�r�rbr�r�rBr�r�r+ZnontermsZnontermZunreachable�ur��infZunused_precZnum_srZnum_rrrhr�Z
resolutionZalready_reportedZruleZrejectedZwarned_neverr	)r�r
�yacc�s�






"



$
















*




*













$$r�)<rlr�rmZos.pathr�rnrhr(r�r�Z	yaccdebugZ
debug_filer�Z
default_lrr�rkrrDrjZ
basestringrsr7�maxsizer�objectrrrOrr%r'r+r/r-r*r,r.r0r4r5r9rVrmr�r�r�r�r�r�r�r�r�r	rrrrKrRrSr�r	r	r	r
�<module>>s�

4m
H.rT
)