Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/lib2to3/pgen2/pgen.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�ddlmZmZmZdejfd��YZdefd��YZdefd��YZdefd	��YZ	d
d�Z
dS(
i(tgrammarttokenttokenizetPgenGrammarcBseZRS((t__name__t
__module__(((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRstParserGeneratorcBs�eZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zdd�Zd�Zd�ZRS(cCs�d}|dkr*t|�}|j}n||_||_tj|j�|_|j	�|j
�\|_|_|dk	r�|�ni|_
|j�dS(N(tNonetopentclosetfilenametstreamRtgenerate_tokenstreadlinet	generatortgettokentparsetdfaststartsymboltfirsttaddfirstsets(tselfR
Rtclose_stream((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyt__init__s		

	cCs�t�}|jj�}|j�|j|j�|jd|j�x;|D]3}dt|j�}||j|<||j	|<qLWx�D]�|j|}g}x�|D]�}g}xE|j
j�D]4\}	}
|j|j
||	�|j|
�f�q�W|jr&|jd|j|�f�n|j|�q�W|jj|�||j||�f|j|j|<q�W|j|j|_|S(Nii(RRtkeystsorttremoveRtinserttlent
symbol2numbert
number2symboltarcst	iteritemstappendt
make_labeltindextisfinaltstatest
make_firsttstart(RtctnamestnametitdfaR%tstateRtlabeltnext((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pytmake_grammars.	





,	*cCsD|j|}i}x*|D]"}|j||�}d||<qW|S(Ni(RR"(RR(R*trawfirstRR.tilabel((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyR&4s

cCs�t|j�}|dj�r�||jkry||jkrH|j|S|jj|j|df�||j|<|Sq�tt|d�}||j	kr�|j	|S|jj|df�||j	|<|Sn�t
|�}|dj�r2||jkr|j|S|jjtj|f�||j|<|SnNt
j|}||j	krY|j	|S|jj|df�||j	|<|SdS(Ni(RtlabelstisalphaRtsymbol2labelR!RtgetattrRttokenstevaltkeywordstNAMERtopmap(RR(R.R2titokentvalue((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyR"=s6




cCsM|jj�}|j�x-|D]%}||jkr |j|�q q WdS(N(RRRRt	calcfirst(RR)R*((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRks


c	Csj|j|}d|j|<|d}i}i}x�|jj�D]�\}}||jkr�||jkr�|j|}|dkr�td|��q�n|j|�|j|}|j|�|||<q@d||<id|6||<q@Wi}	xd|j�D]V\}}
xG|
D]?}||	krGtd||||	|f��n||	|<qWq�|j|<dS(Nisrecursion for rule %risArule %s is ambiguous; %s is in the first sets of %s as well as %s(RRRRR t
ValueErrorR>tupdate(RR*R,R-ttotalsettoverlapcheckR.R/tfsettinversetitsfirsttsymbol((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyR>ss2









c	Cs�i}d}x�|jtjkr� |jtjkrC|j�q$W|jtj�}|jtjd�|j	�\}}|jtj�|j
||�}t|�}|j|�t|�}|||<|dkr|}qqW||fS(Nt:(
RttypeRt	ENDMARKERtNEWLINERtexpectR:tOPt	parse_rhstmake_dfaRtsimplify_dfa(	RRRR*tatzR,toldlentnewlen((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyR�s"


cs�fd�}�fd��t||�|�g}x�|D]�}i}xS|jD]H}x?|jD]4\}}	|dk	rc�|	|j|i��qcqcWqSWxj|j�D]\\}}
x=|D]}|j|
kr�Pq�q�Wt|
|�}|j|�|j||�q�Wq=W|S(Ncsi}�||�|S(N((R-tbase(t
addclosure(s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pytclosure�s
csT||krdSd||<x3|jD](\}}|dkr$�||�q$q$WdS(Ni(RR(R-RTR.R/(RU(s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRU�s
(tDFAStatetnfasetRRt
setdefaultR R!taddarc(RR'tfinishRVR%R-RtnfastateR.R/RXtst((RUs(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRN�s"
$

c
Cs�dG|GH|g}x�t|�D]�\}}dG|G||krEdpHdGHxu|jD]j\}}||kr~|j|�}	nt|�}	|j|�|dkr�d|	GHqTd||	fGHqTWqWdS(NsDump of NFA fors  States(final)ts	    -> %ds    %s -> %d(t	enumerateRR#RR!R(
RR*R'R[ttodoR+R-R.R/tj((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pytdump_nfa�s		
cCs~dG|GHxnt|�D]`\}}dG|G|jr9dp<dGHx5|jj�D]$\}}d||j|�fGHqNWqWdS(NsDump of DFA fors  States(final)R^s    %s -> %d(R_R$RR R#(RR*R,R+R-R.R/((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pytdump_dfa�s
	cCs�t}x�|r�t}x�t|�D]x\}}xit|dt|��D]N}||}||krH||=x|D]}|j||�qrWt}PqHqHWq"Wq	WdS(Ni(tTruetFalseR_trangeRt
unifystate(RR,tchangesR+tstate_iRatstate_jR-((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRO�s	 

cCs�|j�\}}|jdkr+||fSt�}t�}|j|�|j|�xI|jdkr�|j�|j�\}}|j|�|j|�qZW||fSdS(Nt|(t	parse_altR=tNFAStateRZR(RRPRQtaatzz((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRM�s
		



cCsr|j�\}}xS|jdks?|jtjtjfkrg|j�\}}|j|�|}qW||fS(Nt(t[(RpRq(t
parse_itemR=RHRR:tSTRINGRZ(RRPtbR(td((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRl
s

cCs�|jdkrU|j�|j�\}}|jtjd�|j|�||fS|j�\}}|j}|dkr�||fS|j�|j|�|dkr�||fS||fSdS(NRqt]t+t*(RwRx(R=RRMRKRRLRZt
parse_atom(RRPRQR=((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRrs


	



cCs�|jdkrH|j�|j�\}}|jtjd�||fS|jtjtjfkr�t	�}t	�}|j
||j�|j�||fS|jd|j|j�dS(NRpt)s+expected (...) or NAME or STRING, got %s/%s(R=RRMRKRRLRHR:RsRmRZtraise_error(RRPRQ((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRy(s

		

	cCsc|j|ks*|dk	rL|j|krL|jd|||j|j�n|j}|j�|S(Nsexpected %s/%s, got %s/%s(RHRR=R{R(RRHR=((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRK9s*		
cCsi|jj�}x/|dtjtjfkr@|jj�}qW|\|_|_|_|_|_	dS(Ni(
RR/RtCOMMENTtNLRHR=tbegintendtline(Rttup((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRAscGss|r@y||}Wq@dj|gtt|��}q@Xnt||j|jd|jd|jf��dS(Nt ii(tjointmaptstrtSyntaxErrorR
RR�(Rtmsgtargs((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyR{Hs&N(RRRRR0R&R"RR>RRNRbRcRORMRlRrRyRKRR{(((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyR
s$				.				$					
			RmcBseZd�Zdd�ZRS(cCs
g|_dS(N(R(R((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRSscCs|jj||f�dS(N(RR!(RR/R.((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRZVsN(RRRRRZ(((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRmQs	RWcBs2eZd�Zd�Zd�Zd�ZdZRS(cCs%||_||k|_i|_dS(N(RXR$R(RRXtfinal((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyR]s	cCs||j|<dS(N(R(RR/R.((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRZescCs@x9|jj�D](\}}||kr||j|<qqWdS(N(RR (RtoldtnewR.R/((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRgkscCsx|j|jkrtSt|j�t|j�kr8tSx9|jj�D](\}}||jj|�k	rHtSqHWtS(N(R$ReRRR tgetRd(RtotherR.R/((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyt__eq__psN(RRRRZRgR�Rt__hash__(((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyRW[s
				sGrammar.txtcCst|�}|j�S(N(RR0(R
tp((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pytgenerate_grammar�sN(R^RRRtGrammarRtobjectRRmRWR�(((s(/sys/lib/python2.7/lib2to3/pgen2/pgen.pyt<module>s�
%

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.