ó ÿgdSc@swdZdefd„ƒYZdefd„ƒYZdefd„ƒYZd„Zed„Zd efd „ƒYZd S( sÉ sphinx.pycode.nodes ~~~~~~~~~~~~~~~~~~~ Parse tree node implementations. :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. tBaseNodecBskeZdZd Zd„Zd„Zd„Zd Zd„Z d„Z d„Z d„Z d„Z d „ZRS( sB Node superclass for both terminal and nonterminal nodes. cCs t‚dS(N(tNotImplementedError(tselftother((ssphinx/pycode/nodes.pyt_eqscCs#|j|jk rtS|j|ƒS(N(t __class__tNotImplementedR(RR((ssphinx/pycode/nodes.pyt__eq__scCs$|j|jk rtS|j|ƒ S(N(RRR(RR((ssphinx/pycode/nodes.pyt__ne__scCsh|jdkrdSxNt|jjƒD]:\}}||kr&|dkrNdS|jj|dSq&WdS(s4Return previous child in parent's children, or None.iiN(tparenttNonet enumeratetchildren(Rtitchild((ssphinx/pycode/nodes.pytget_prev_sibling"s  cCst|jdkrdSxZt|jjƒD]F\}}||kr&y|jj|dSWqltk rhdSXq&q&WdS(s0Return next child in parent's children, or None.iN(R R R R t IndexError(RR R((ssphinx/pycode/nodes.pytget_next_sibling,s  csd‡fd†‰|jdkr"dS|jƒ}t|tƒrA|S|dk rWˆ|ƒS|jjƒS(s?Return the leaf node that precedes this node in the parse tree.cs5t|tƒr|S|js dSˆ|jdƒSdS(Niÿÿÿÿ(t isinstancetLeafR R (tnode(t last_child(ssphinx/pycode/nodes.pyR9s  N(R R RRRt get_prev_leaf(Rtprev((Rssphinx/pycode/nodes.pyR7s   cCs<|}x/t|tƒs7|js't‚|jd}q W|S(shReturn self if leaf, otherwise the leaf node that succeeds this node in the parse tree. i(RRR tAssertionError(RR((ssphinx/pycode/nodes.pyt get_next_leafIs cCs |jƒjS(s9Return the line number which generated the invocant node.(Rtlineno(R((ssphinx/pycode/nodes.pyt get_linenoSscCs |jƒjS(s(Return the prefix of the next leaf node.(Rtprefix(R((ssphinx/pycode/nodes.pyt get_prefixWsN(t__name__t __module__t__doc__R R RRRt__hash__RRRRRR(((ssphinx/pycode/nodes.pyR s     tNodecBsPeZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( s/ Node implementation for nonterminals. cCs9||_t|ƒ|_x|jD]}||_q"WdS(N(ttypetlistR R (RR#R tcontexttch((ssphinx/pycode/nodes.pyt__init__bs cCsd|jj|j|jfS(Ns %s(%s, %r)(RRR#R (R((ssphinx/pycode/nodes.pyt__repr__ks cCsdjtt|jƒƒS(s)This reproduces the input source exactly.t(tjointmaptstrR (R((ssphinx/pycode/nodes.pyt__str__oscCs"|j|jf|j|jfkS(N(R#R (RR((ssphinx/pycode/nodes.pyRsscCs |j|S(N(R (Rtindex((ssphinx/pycode/nodes.pyt __getitem__xscCs t|jƒS(N(titerR (R((ssphinx/pycode/nodes.pyt__iter__{scCs t|jƒS(N(tlenR (R((ssphinx/pycode/nodes.pyt__len__~sN( RRR R R'R(R-RR/R1R3(((ssphinx/pycode/nodes.pyR"]s     RcBsGeZdZdZdZdZdd„Zd„Zd„Z d„Z RS(s9 Node implementation for leaf nodes (terminals). R)icCs@||_||_|dk r<|\|_\|_|_ndS(N(R#tvalueR RRtcolumn(RR#R4R%((ssphinx/pycode/nodes.pyR'Šs   cCs#d|jj|j|j|jfS(Ns%s(%r, %r, %r)(RRR#R4R(R((ssphinx/pycode/nodes.pyR(’s cCs|jt|jƒS(s)This reproduces the input source exactly.(RR,R4(R((ssphinx/pycode/nodes.pyR-–scCs"|j|jf|j|jfkS(s Compares two nodes for equality.(R#R4(RR((ssphinx/pycode/nodes.pyRšsN( RRR RRR5R R'R(R-R(((ssphinx/pycode/nodes.pyR‚s   cCsk|\}}}}|s'||jkrTt|ƒdkrA|dSt||d|ƒSt||d|ƒSdS(s,Convert raw node to a Node or Leaf instance.iiR%N(t number2symbolR2R"R(tgrammartraw_nodeR#R4R%R ((ssphinx/pycode/nodes.pytconvertŸs cs:‡‡fd†‰‡‡fd†‰|r0ˆp3ˆ|ƒS(NcsUt|tƒr'dˆ|j|jfSdˆ|jdjtˆ|jƒƒfSdS(Ns%s(%r)s%s(%s)s, (RRR#R4R*R+R (R(t_reprt number2name(ssphinx/pycode/nodes.pyR:­s cs[t|tƒr-dˆ|j|j|jfSdˆ|jdjtˆ|jƒƒfSdS(Ns %s(%r, %r)s%s(%s)s, (RRR#RR4R*R+R (R(t_preprR;(ssphinx/pycode/nodes.pyR<³s   ((RR;R((R<R:R;ssphinx/pycode/nodes.pyt nice_repr¬st NodeVisitorcBs,eZd„Zd„Zd„Zd„ZRS(cGs||_|j|ŒdS(N(R;tinit(RR;targs((ssphinx/pycode/nodes.pyR'¾s cGsdS(N((RR@((ssphinx/pycode/nodes.pyR?ÂscCs3d|j|j}t|||jƒ}||ƒS(s Visit a node.tvisit_(R;R#tgetattrt generic_visit(RRtmethodtvisitor((ssphinx/pycode/nodes.pytvisitÅscCs4t|tƒr0x|D]}|j|ƒqWndS(s9Called if no explicit visitor function exists for a node.N(RR"RF(RRR((ssphinx/pycode/nodes.pyRCËs (RRR'R?RFRC(((ssphinx/pycode/nodes.pyR>½s   N( R tobjectRR"RR9tFalseR=R>(((ssphinx/pycode/nodes.pyt s P%