�t�c@s6ddlZddlmZdefd��YZdS(i�N(t_tparsercBsMeZdd�Zd�Zd�Zdd�Zd�Zd�Zd�Z RS( cCs(||_||_||_d|_dS(N(t
_tokenizert _elementst_methodstNonetcurrent(tselft tokenizertelementstmethods((s4/sys/lib/python2.7/site-packages/mercurial/parser.pyt__init__s cCs7|j}y|jj�|_Wntk
r2nX|S(sadvance the tokenizer(Rt_itertnextt
StopIteration(Rtt((s4/sys/lib/python2.7/site-packages/mercurial/parser.pyt_advances
cCsN|jd|kr@tjtd�|jd|jd��n|j�dS(s0make sure the tokenizer matches an end conditionisunexpected token: %siN(Rterrort
ParseErrorRR(Rtmtpos((s4/sys/lib/python2.7/site-packages/mercurial/parser.pyt_match#sic
Cs{|j�\}}}|j|d}|sKtjtd�||��nt|�dkrp|d|f}n�t|�dkr�|d|jdkr�|j|d|�|ddf}nF|d|j |d�f}t|�dkr|j|d|�nxn||j|jddkrv|j�\}}}|j|}t|�dkr�|j|jddr�|d}|d|f}q t|�dks�|dr�tjtd�||��n|d} t| �dkr*| d|jdkr*|j| d|�| d|df}q | d||j | d�f}t| �dkr |j| d|�q q W|S(Nisnot a prefix: %siiiisnot an infix: %s(
RRRRRtlenRRRt_parse(
RtbindttokentvalueRtprefixtexprtetsuffixtinfix((s4/sys/lib/python2.7/site-packages/mercurial/parser.pyR)s8)!
+
) cCsD|j|�|_|j�|j�}|j\}}}||fS(s$generate a parse tree from a message(RRRRR(RtmessagetresRRR((s4/sys/lib/python2.7/site-packages/mercurial/parser.pytparseNs
cCsHt|t�s|S|j|dg|dD]}|j|�^q,�S(s4recursively evaluate a parse tree using node methodsii(t
isinstancettupleRteval(RttreeR((s4/sys/lib/python2.7/site-packages/mercurial/parser.pyR%UscCs)|j|�}|jr%|j|�S|S(s?parse a message into a parse tree and evaluate if methods given(R"RR%(RR R((s4/sys/lib/python2.7/site-packages/mercurial/parser.pyt__call__Zs
N(
t__name__t
__module__RRRRRR"R%R'(((s4/sys/lib/python2.7/site-packages/mercurial/parser.pyRs % (Rti18nRtobjectR(((s4/sys/lib/python2.7/site-packages/mercurial/parser.pyt<module>s
|