�`^c@s�ddlmZmZmZdejfd��YZdefd��YZdefd��YZdefd ��YZ d
d�Z
dS(
i(tgrammarttokenttokenizetPgenGrammarcBseZRS((t__name__t
__module__(((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRstParserGeneratorcBs�eZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d�Zd �Zd
�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 generatortgettokentparsetdfaststartsymboltfirsttaddfirstsets(tselfR
Rtclose_stream((s3/usr/stallion/src/cpython/Lib/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&|jd|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((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pytmake_grammars.
, *cCsD|j|}i}x*|D]"}|j||�}d||<qW|S(Ni(RR"(RR(R*trawfirstRR.tilabel((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR&4s
cCs�t|j�}|dj�r||jkry||jkrH|j|S|jj|j|df�||j|<|Sq�tt|d�}t |t
�s�t|��|tjks�t|��||j
kr�|j
|S|jj|df�||j
|<|Sn�|ddks!t|��t|�}|dj�r�||jkrW|j|S|jjtj|f�||j|<|SnNtj|}||j
kr�|j
|S|jj|df�||j
|<|SdS(Nit"t'(R3R4(RtlabelstisalphaRtsymbol2labelR!RtgetattrRt
isinstancetinttAssertionErrorttok_namettokenstevaltkeywordstNAMERtopmap(RR(R.R2titokentvalue((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR"=s<
cCsM|jj�}|j�x-|D]%}||jkr |j|�q q WdS(N(RRRRt calcfirst(RR)R*((s3/usr/stallion/src/cpython/Lib/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
ValueErrorRDtupdate(RR*R,R-ttotalsettoverlapcheckR.R/tfsettinversetitsfirsttsymbol((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRDss2
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_dfaRtsimplify_dfa( RRRR*tatzR,toldlentnewlen((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR�s"
cs>t|t�st�t|t�s*t��fd�}�fd��t||�|�g}x�|D]�}i}xS|jD]H}x?|jD]4\}} |dk r��| |j|i��q�q�Wq}Wxj|j�D]\\}}
x=|D]}|j|
kr�q��t|
|�}|j |�|j
||�q�WqgW|S(Ncsi}�||�|S(N((R-tbase(t
addclosure(s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pytclosure�s
csit|t�st�||kr%dSd||<x3|jD](\}}|dkr9�||�q9q9WdS(Ni(R9tNFAStateR;RR(R-RZR.R/(R[(s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR[�s
(R9R]R;tDFAStatetnfasetRRt
setdefaultR R!taddarc(RR'tfinishR\R%R-RtnfastateR.R/R_tst((R[s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRT�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'RbttodoR+R-R.R/tj((s3/usr/stallion/src/cpython/Lib/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)Res %s -> %d(RfR$RR R#(RR*R,R+R-R.R/((s3/usr/stallion/src/cpython/Lib/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(tTruetFalseRftrangeRt
unifystate(RR,tchangesR+tstate_iRhtstate_jR-((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRU�s
cCs�|j�\}}|jdkr+||fSt�}t�}|j|�|j|�xI|jdkr�|j�|j�\}}|j|�|j|�qZW||fSdS(Nt|(t parse_altRCR]RaR(RRVRWtaatzz((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRS�s
cCsr|j�\}}xS|jdks?|jtjtjfkrg|j�\}}|j|�|}qW||fS(Nt(t[(RvRw(t
parse_itemRCRNRR@tSTRINGRa(RRVtbR(td((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRs
s
cCs�|jdkrU|j�|j�\}}|jtjd�|j|�||fS|j�\}}|j}|dkr�||fS|j�|j|�|dkr�||fS||fSdS(NRwt]t+t*(R}R~(RCRRSRQRRRRat
parse_atom(RRVRWRC((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRxs
cCs�|jdkrH|j�|j�\}}|jtjd�||fS|jtjtjfkr�t �}t �}|j
||j�|j�||fS|jd|j|j�dS(NRvt)s+expected (...) or NAME or STRING, got %s/%s(RCRRSRQRRRRNR@RyR]Ratraise_error(RRVRW((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR(s
cCsc|j|ks*|dk rL|j|krL|jd|||j|j�n|j}|j�|S(Nsexpected %s/%s, got %s/%s(RNRRCR�R(RRNRC((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRQ9s*
cCsi|jj�}x/|dtjtjfkr@|jj�}qW|\|_|_|_|_|_ dS(Ni(
RR/RtCOMMENTtNLRNRCtbegintendtline(Rttup((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRAscGss|r@y||}Wq@dj|gtt|��}q@Xnt||j|jd|jd|jf��dS(Nt ii(tjointmaptstrtSyntaxErrorR
R�R�(Rtmsgtargs((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR�Hs&N(RRRRR0R&R"RRDRRTRiRjRURSRsRxRRQRR�(((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR
s$ . $
R]cBseZd�Zdd�ZRS(cCs
g|_dS(N(R(R((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRSscCsP|dks!t|t�s!t�t|t�s6t�|jj||f�dS(N(RR9R�R;R]RR!(RR/R.((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRaVs!N(RRRRRa(((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR]Qs R^cBs2eZd�Zd�Zd�Zd�ZdZRS(cCspt|t�st�tt|�j�t�s6t�t|t�sKt�||_||k|_i|_dS(N( R9tdictR;titerR/R]R_R$R(RR_tfinal((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR]s! cCsPt|t�st�||jks*t�t|t�s?t�||j|<dS(N(R9R�R;RR^(RR/R.((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRaescCs@x9|jj�D](\}}||kr||j|<qqWdS(N(RR (RtoldtnewR.R/((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyRnkscCs�t|t�st�|j|jkr+tSt|j�t|j�krMtSx9|jj�D](\}}||jj|�k r]tSq]Wt S(N(
R9R^R;R$RlRRR tgetRk(RtotherR.R/((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyt__eq__psN(RRRRaRnR�Rt__hash__(((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyR^[s
sGrammar.txtcCst|�}|j�S(N(RR0(R
tp((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pytgenerate_grammar�sN(ReRRRtGrammarRtobjectRR]R^R�(((s3/usr/stallion/src/cpython/Lib/lib2to3/pgen2/pgen.pyt<module>s�
%
|