
V}Oc        	   @   sP  d  Z  d d k Z d d k l Z l Z l Z l Z d d k l Z l	 Z	 d d k
 l Z d d k l Z l Z l Z d d k l Z l Z l Z l Z l Z d e f d	     YZ d
 e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ e e  Z  d e f d     YZ! d e f d     YZ" d e f d     YZ# d e# f d     YZ$ d  e f d!     YZ% d" e f d#     YZ& d$ e f d%     YZ' d& e' f d'     YZ( d( e' f d)     YZ) d* e' f d+     YZ* d, e	 f d-     YZ+ d S(.   s    @package antlr3.tree
@brief ANTLR3 runtime package, tree module

This module contains all support classes for AST construction and tree parsers.

iN(   t   UPt   DOWNt   EOFt   INVALID_TOKEN_TYPE(   t   BaseRecognizert   RuleReturnScope(   t	   IntStream(   t   CommonTokent   Tokent   INVALID_TOKEN(   t   MismatchedTreeNodeExceptiont   MissingTokenExceptiont   UnwantedTokenExceptiont   MismatchedTokenExceptiont   NoViableAltExceptiont   RewriteCardinalityExceptionc           B   s    e  Z d  Z d   Z d   Z RS(   s   
    @brief Base class for all exceptions thrown during AST rewrite construction.

    This signifies a case where the cardinality of two or more elements
    in a subrule are different: (ID INT)+ where |ID|!=|INT|
    c         C   s   t  i |  |  | |  _ d  S(   N(   t   RuntimeErrort   __init__t   elementDescription(   t   selfR   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   C   s    c         C   s   |  i  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt
   getMessageI   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   ;   s   	t   RewriteEarlyExitExceptionc           B   s   e  Z d  Z d d  Z RS(   s4   @brief No elements within a (...)+ in a rewrite rulec         C   s   t  i |  |  d  S(   N(   R   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   P   s    N(   R   R   R   t   NoneR   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   M   s   t   RewriteEmptyStreamExceptionc           B   s   e  Z d  Z RS(   sX   
    @brief Ref to ID or expr but no tokens in ID stream or subtrees in expr stream
    (   R   R   R   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   T   s   t   Treec           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s.  
    @brief Abstract baseclass for tree nodes.
    
    What does a tree look like?  ANTLR has a number of support classes
    such as CommonTreeNodeStream that work on these kinds of trees.  You
    don't have to make your trees implement this interface, but if you do,
    you'll be able to use more support code.

    NOTE: When constructing trees, ANTLR can build any kind of tree; it can
    even use Token objects as trees if you add a child list to your tokens.
    
    This is a tree node without any payload; just navigation and factory stuff.
    c         C   s
   t   d  S(   N(   t   NotImplementedError(   R   t   i(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getChildr   s    c         C   s
   t   d  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getChildCountv   s    c         C   s
   t   d S(   s,   Tree tracks parent and child index now > 3.0N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt	   getParentz   s    c         C   s
   t   d S(   s,   Tree tracks parent and child index now > 3.0N(   R   (   R   t   t(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt	   setParent   s    c         C   s
   t   d S(   s7   Walk upwards looking for ancestor with this token type.N(   R   (   R   t   ttype(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   hasAncestor   s    c         C   s
   t   d S(   s9   Walk upwards and get first ancestor with this token type.N(   R   (   R   R#   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getAncestor   s    c         C   s
   t   d S(   s   Return a list of all ancestors of this node.

        The first node of list is the root and the last is the parent of
        this node.
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getAncestors   s    c         C   s
   t   d S(   s%   This node is what child index? 0..n-1N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getChildIndex   s    c         C   s
   t   d S(   s%   This node is what child index? 0..n-1N(   R   (   R   t   index(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setChildIndex   s    c         C   s
   t   d S(   s6   Set the parent and child index values for all childrenN(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   freshenParentAndChildIndexes   s    c         C   s
   t   d S(   s   
        Add t as a child to this node.  If t is null, do nothing.  If t
        is nil, add all children of t to this' children.
        N(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   addChild   s    c         C   s
   t   d S(   s@   Set ith child (0..n-1) to t; t must be non-null and non-nil nodeN(   R   (   R   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setChild   s    c         C   s
   t   d  S(   N(   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   deleteChild   s    c         C   s
   t   d S(   s#  
        Delete children from start to stop and replace with t even if t is
        a list (nil-root tree).  num of children can increase or decrease.
        For huge child lists, inserting children can force walking rest of
        children to set their childindex; could be slow.
        N(   R   (   R   t   startChildIndext   stopChildIndexR!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   replaceChildren   s    c         C   s
   t   d S(   sx   
        Indicates the node is a nil node but may still have children, meaning
        the tree is a flat list.
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   isNil   s    c         C   s
   t   d S(   so   
        What is the smallest token index (indexing from 0) for this node
           and its children?
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getTokenStartIndex   s    c         C   s
   t   d  S(   N(   R   (   R   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setTokenStartIndex   s    c         C   s
   t   d S(   sk   
        What is the largest token index (indexing from 0) for this node
        and its children?
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getTokenStopIndex   s    c         C   s
   t   d  S(   N(   R   (   R   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setTokenStopIndex   s    c         C   s
   t   d  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   dupNode   s    c         C   s
   t   d S(   s-   Return a token type; needed for tree parsing.N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getType   s    c         C   s
   t   d  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getText   s    c         C   s
   t   d S(   sU   
        In case we don't have a token payload, what is the line for errors?
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getLine   s    c         C   s
   t   d  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getCharPositionInLine  s    c         C   s
   t   d  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   toStringTree  s    c         C   s
   t   d  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   toString	  s    (   R   R   R   R   R   R    R"   R$   R%   R&   R'   R)   R*   R+   R,   R-   R0   R1   R2   R3   R4   R5   R6   R7   R8   R9   R:   R;   R<   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   b   s6   							
																						t   TreeAdaptorc           B   s  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! RS(    s  
    @brief Abstract baseclass for tree adaptors.
    
    How to create and navigate trees.  Rather than have a separate factory
    and adaptor, I've merged them.  Makes sense to encapsulate.

    This takes the place of the tree construction code generated in the
    generated code in 2.x and the ASTFactory.

    I do not need to know the type of a tree at all so they are all
    generic Objects.  This may increase the amount of typecasting needed. :(
    c         C   s
   t   d S(   s   
        Create a tree node from Token object; for CommonTree type trees,
        then the token just becomes the payload.  This is the most
        common create call.

        Override if you want another kind of node to be built.
        N(   R   (   R   t   payload(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   createWithPayload  s    	c         C   s
   t   d S(   s]   Duplicate a single tree node.

        Override if you want another kind of node to be built.N(   R   (   R   t   treeNode(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR6   *  s    c         C   s
   t   d S(   s9   Duplicate tree recursively, using dupNode() for each nodeN(   R   (   R   t   tree(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   dupTree2  s    c         C   s
   t   d S(   s   
        Return a nil node (an empty but non-null node) that can hold
        a list of element as the children.  If you want a flat tree (a list)
        use "t=adaptor.nil(); t.addChild(x); t.addChild(y);"
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   nil8  s    c         C   s
   t   d S(   s  
        Return a tree node representing an error.  This node records the
        tokens consumed during error recovery.  The start token indicates the
        input symbol at which the error was detected.  The stop token indicates
        the last symbol consumed during recovery.

        You must specify the input stream so that the erroneous text can
        be packaged up in the error node.  The exception could be useful
        to some applications; default implementation stores ptr to it in
        the CommonErrorNode.

        This only makes sense during token parsing, not tree parsing.
        Tree parsing should happen only when parsing and tree construction
        succeed.
        N(   R   (   R   t   inputt   startt   stopt   exc(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt	   errorNodeB  s    c         C   s
   t   d S(   s@   Is tree considered a nil node used to make lists of child nodes?N(   R   (   R   RA   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR1   V  s    c         C   s
   t   d S(   s  
        Add a child to the tree t.  If child is a flat tree (a list), make all
        in list children of t.  Warning: if t has no children, but child does
        and child isNil then you can decide it is ok to move children to t via
        t.children = child.children; i.e., without copying the array.  Just
        make sure that this is consistent with have the user will build
        ASTs. Do nothing if t or child is null.
        N(   R   (   R   R!   t   child(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR+   \  s    
c         C   s
   t   d S(   s-  
        If oldRoot is a nil root, just copy or move the children to newRoot.
        If not a nil root, make oldRoot a child of newRoot.
        
           old=^(nil a b c), new=r yields ^(r a b c)
           old=^(a b c), new=r yields ^(r ^(a b c))

        If newRoot is a nil-rooted single child tree, use the single
        child as the new root node.

           old=^(nil a b c), new=^(nil r) yields ^(r a b c)
           old=^(a b c), new=^(nil r) yields ^(r ^(a b c))

        If oldRoot was null, it's ok, just return newRoot (even if isNil).

           old=null, new=r yields r
           old=null, new=^(nil r) yields ^(nil r)

        Return newRoot.  Throw an exception if newRoot is not a
        simple node or nil root with a single child node--it must be a root
        node.  If newRoot is ^(nil x) return x as newRoot.

        Be advised that it's ok for newRoot to point at oldRoot's
        children; i.e., you don't have to copy the list.  We are
        constructing these nodes so we should have this control for
        efficiency.
        N(   R   (   R   t   newRoott   oldRoot(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt
   becomeRooti  s    c         C   s
   t   d S(   sn  
        Given the root of the subtree created for this rule, post process
        it to do any simplifications or whatever you want.  A required
        behavior is to convert ^(nil singleSubtree) to singleSubtree
        as the setting of start/stop indexes relies on a single non-nil root
        for non-flat trees.

        Flat trees such as for lists like "idlist : ID+ ;" are left alone
        unless there is only one ID.  For a list, the start/stop indexes
        are set in the nil node.

        This method is executed after all rule tree construction and right
        before setTokenBoundaries().
        N(   R   (   R   t   root(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   rulePostProcessing  s    c         C   s
   t   d S(   s   For identifying trees.

        How to identify nodes so we can say "add node to a prior node"?
        Even becomeRoot is an issue.  Use System.identityHashCode(node)
        usually.
        N(   R   (   R   t   node(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getUniqueID  s    c         C   s
   t   d S(   s0  
        Create a new node derived from a token, with a new token type and
        (optionally) new text.

        This is invoked from an imaginary node ref on right side of a
        rewrite rule as IMAG[$tokenLabel] or IMAG[$tokenLabel "IMAG"].

        This should invoke createToken(Token).
        N(   R   (   R   t	   tokenTypet	   fromTokent   text(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   createFromToken  s    c         C   s
   t   d S(   s   Create a new node derived from a token, with a new token type.

        This is invoked from an imaginary node ref on right side of a
        rewrite rule as IMAG["IMAG"].

        This should invoke createToken(int,String).
        N(   R   (   R   RQ   RS   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   createFromType  s    	c         C   s
   t   d S(   s9   For tree parsing, I need to know the token type of a nodeN(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR7     s    c         C   s
   t   d S(   s,   Node constructors can set the type of a nodeN(   R   (   R   R!   t   type(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setType  s    c         C   s
   t   d  S(   N(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR8     s    c         C   s
   t   d S(   s,   Node constructors can set the text of a nodeN(   R   (   R   R!   RS   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setText  s    c         C   s
   t   d S(   s  Return the token object from which this node was created.

        Currently used only for printing an error message.
        The error display routine in BaseRecognizer needs to
        display where the input the error occurred. If your
        tree of limitation does not store information that can
        lead you to the token, you can create a token filled with
        the appropriate information and pass that back.  See
        BaseRecognizer.getErrorMessage().
        N(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getToken  s    c         C   s
   t   d S(   sg  
        Where are the bounds in the input token stream for this node and
        all children?  Each rule that creates AST nodes will call this
        method right before returning.  Flat trees (i.e., lists) will
        still usually have a nil root node just to hold the children list.
        That node would contain the start/stop indexes then.
        N(   R   (   R   R!   t
   startTokent	   stopToken(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setTokenBoundaries  s    	c         C   s
   t   d S(   sX   
        Get the token start index for this subtree; return -1 if no such index
        N(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR2     s    c         C   s
   t   d S(   sW   
        Get the token stop index for this subtree; return -1 if no such index
        N(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR4     s    c         C   s
   t   d S(   s   Get a child 0..n-1 nodeN(   R   (   R   R!   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s
   t   d S(   s@   Set ith child (0..n-1) to t; t must be non-null and non-nil nodeN(   R   (   R   R!   R   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR,     s    c         C   s
   t   d S(   s4   Remove ith child and shift children down from right.N(   R   (   R   R!   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR-     s    c         C   s
   t   d S(   s2   How many children?  If 0, then this is a leaf nodeN(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s
   t   d S(   s   
        Who is the parent node of this node; if null, implies node is root.
        If your node type doesn't handle this, it's ok but the tree rewrites
        in tree parsers need this functionality.
        N(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR      s    c         C   s
   t   d S(   s   
        Who is the parent node of this node; if null, implies node is root.
        If your node type doesn't handle this, it's ok but the tree rewrites
        in tree parsers need this functionality.
        N(   R   (   R   R!   t   parent(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR"   )  s    c         C   s
   t   d S(   s   
        What index is this node in the child list? Range: 0..n-1
        If your node type doesn't handle this, it's ok but the tree rewrites
        in tree parsers need this functionality.
        N(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR'   3  s    c         C   s
   t   d S(   s   
        What index is this node in the child list? Range: 0..n-1
        If your node type doesn't handle this, it's ok but the tree rewrites
        in tree parsers need this functionality.
        N(   R   (   R   R!   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR)   =  s    c         C   s
   t   d S(   sD  
        Replace from start to stop child index of parent with t, which might
        be a list.  Number of children may be different
        after this call.

        If parent is null, don't do anything; must be at root of overall tree.
        Can't replace whatever points to the parent externally.  Do nothing.
        N(   R   (   R   R]   R.   R/   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR0   G  s    
c         G   s  t  |  d j o& t | d t  o |  i | d  St  |  d j oG t | d t t f  o- t | d t  o |  i | d | d  St  |  d j ob t | d t t f  oH t | d t  o4 t | d t  o  |  i | d | d | d  St  |  d j oG t | d t t f  o- t | d t  o |  i | d | d  St	 d d i
 d   | D    d S(	   s   
        Deprecated, use createWithPayload, createFromToken or createFromType.

        This method only exists to mimic the Java interface of TreeAdaptor.
        
        i   i    i   i   s.   No create method with this signature found: %ss   , c         s   s"   x |  ] } t  |  i Vq Wd  S(   N(   RV   R   (   t   .0t   v(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pys	   <genexpr>  s   	 N(   t   lent
   isinstanceR   R?   t   intt   longRT   t
   basestringRU   t	   TypeErrort   join(   R   t   args(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   createV  s$    ' N("   R   R   R   R?   R6   RB   RC   RH   R1   R+   RL   RN   RP   R   RT   RU   R7   RW   R8   RX   RY   R\   R2   R4   R   R,   R-   R   R    R"   R'   R)   R0   Rh   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR=     s>   				
				 											
					
	
	
	
	t   BaseTreec           B   s   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d d  Z d d d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   sV  
    @brief A generic tree implementation with no payload.

    You must subclass to
    actually have any user data.  ANTLR v3 uses a list of children approach
    instead of the child-sibling approach in v2.  A flat tree (a list) is
    an empty node whose children represent the list.  An empty, but
    non-null node is called "nil".
    c         C   s,   t  i |   g  |  _ d |  _ d |  _ d S(   s   
        Create a new node from an existing node does nothing for BaseTree
        as there are no fields other than the children list, which cannot
        be copied as the children are not considered part of this node. 
        i    N(   R   R   t   childrenR   R]   t
   childIndex(   R   RO   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    		c         C   s*   y |  i  | SWn t j
 o d  SXd  S(   N(   Rj   t
   IndexErrorR   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   |  i  S(   s   @brief Get the children internal List

        Note that if you directly mess with
        the list, do so at your own risk.
        (   Rj   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getChildren  s    c         C   s0   x) |  i  D] } | i   | j o | Sq
 Wd  S(   N(   Rj   R7   R   (   R   t   treeTypeRI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getFirstChildWithType  s
    
 	c         C   s   t  |  i  S(   N(   R`   Rj   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   | d j o d S| i   ox |  i | i j o t d   n x< t | i  D]+ \ } } |  | _ t |  i  | | _ qR W|  i | i 7_ n0 |  i i |  |  | _ t |  i  d | _ d S(   s   Add t as child of this node.

        Warning: if t has no children, but child does
        and child isNil then this routine moves children to t via
        t.children = child.children; i.e., without copying the array.
        Ns#   attempt to add child list to itselfi   (	   R   R1   Rj   t
   ValueErrort	   enumerateR]   R`   Rk   t   append(   R   t	   childTreet   idxRI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR+     s     		c         C   s   |  i  | 7_  d S(   s6   Add all elements of kids list as children of this nodeN(   Rj   (   R   Rj   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   addChildren  s    c         C   sR   | d  j o d  S| i   o t d   n | |  i | <|  | _ | | _ d  S(   Ns    Can't set single child to a list(   R   R1   Rp   Rj   R]   Rk   (   R   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR,     s    	c         C   sL   |  i  | } |  i  | =x. t |  i  |  D] \ } } | | | _ q+ W| S(   N(   Rj   Rq   Rk   (   R   R   t   killedRt   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR-     s    
 c   
      C   s
  | t  |  i  j p | t  |  i  j o t d   n | | d } | i   o | i } n
 | g } t  |  } | | } | d j oH xs t |  D]3 \ } }	 |	 |  i | | <|  |	 _ | | |	 _ q Wn/ |  i | | d 5| |  i | | +|  i |  d S(   s#  
        Delete children from start to stop and replace with t even if t is
        a list (nil-root tree).  num of children can increase or decrease.
        For huge child lists, inserting children can force walking rest of
        children to set their childindex; could be slow.
        s   indexes invalidi   i    N(   R`   Rj   Rl   R1   Rq   R]   Rk   R*   (
   R   R.   R/   t   newTreet   replacingHowManyt   newChildrent   replacingWithHowManyt   deltaRt   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR0     s$    	
 	c         C   s   t  S(   N(   t   False(   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR1   G  s    i    c         C   s>   x7 t  |  i |  D]" \ } } | | | _ |  | _ q Wd  S(   N(   Rq   Rj   Rk   R]   (   R   t   offsetRt   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR*   K  s     ic         C   s   | |  i  j o t d | |  i  f   n | |  i j o t d | |  i f   n x- t |  i  D] \ } } | i |  |  qj Wd  S(   Ns)   parents don't match; expected %r found %rs/   child indexes don't match; expected %d found %d(   R]   Rp   Rk   Rq   Rj   t    sanityCheckParentAndChildIndexes(   R   R]   R   Rt   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR~   Q  s     c         C   s   d S(   s%   BaseTree doesn't track child indexes.i    (    (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR'   b  s    c         C   s   d S(   s%   BaseTree doesn't track child indexes.N(    (   R   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR)   h  s    c         C   s   d S(   s'   BaseTree doesn't track parent pointers.N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR    n  s    c         C   s   d S(   s'   BaseTree doesn't track parent pointers.N(    (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR"   s  s    c         C   s   |  i  |  d j	 S(   s7   Walk upwards looking for ancestor with this token type.N(   R%   R   (   R   R#   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR$   y  s    c         C   sI   |  i    } x6 | d j	 o( | i   | j o | S| i    } q Wd S(   s9   Walk upwards and get first ancestor with this token type.N(   R    R   R7   (   R   R#   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR%   }  s     c         C   s\   t    d j o d Sg  } |  i   } x. | d j	 o  | i d |  | i   } q* W| S(   s   Return a list of all ancestors of this node.

        The first node of list is the root and the last is the parent of
        this node.
        i    N(   t   selfgetParentR   R    t   insert(   R   t	   ancestorsR!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR&     s     c         C   s   t  |  i  d j o |  i   Sg  } |  i   p1 | i d  | i |  i    | i d  n xN t |  i  D]= \ } } | d j o | i d  n | i | i    qu W|  i   p | i d  n d i |  S(   s&   Print out a whole tree not just a nodei    t   (t    t   )t    (   R`   Rj   R<   R1   Rr   Rq   R;   Rf   (   R   t   bufR   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR;     s     c         C   s   d S(   Ni    (    (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR9     s    c         C   s   d S(   Ni    (    (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR:     s    c         C   s
   t   d S(   s;   Override to say how a node (not a tree) should look as textN(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR<     s    N(   R   R   R   R   R   R   Rm   Ro   R   R+   Ru   R,   R-   R0   R1   R*   R~   R'   R)   R    R"   R$   R%   R&   R;   R9   R:   R<   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRi     s2   						"				.							
				t   BaseTreeAdaptorc           B   s   e  Z d  Z d   Z d   Z d   Z d d  Z d   Z d   Z	 d   Z
 d d  Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d d d  Z RS(   sG   
    @brief A TreeAdaptor that works with any Tree implementation.
    c         C   s   |  i  d   S(   N(   R?   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRC     s    c         C   s   t  | | | |  S(   s  
        create tree node that holds the start and stop tokens associated
        with an error.

        If you specify your own kind of tree nodes, you will likely have to
        override this method. CommonTree returns Token.INVALID_TOKEN_TYPE
        if no token payload but you might have to set token type for diff
        node type.

        You don't have to subclass CommonErrorNode; you will likely need to
        subclass your own tree node class to avoid class cast exception.
        (   t   CommonErrorNode(   R   RD   RE   RF   RG   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRH     s    c         C   s
   | i    S(   N(   R1   (   R   RA   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR1     s    c         C   s   | d j o d S|  i |  } |  i | |  i |   |  i | |  xQ t |  i |   D]: } |  i | |  } |  i | |  } |  i	 | |  q` W| S(   s   
        This is generic in the sense that it will work with any kind of
        tree (not just Tree interface).  It invokes the adaptor routines
        not the tree node routines to do the construction.
        N(
   R   R6   R)   R'   R"   t   rangeR   R   RB   R+   (   R   R!   R]   Rw   R   RI   t
   newSubTree(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRB     s     c         C   s/   | d j	 o | d j	 o | i |  n d S(   s  
        Add a child to the tree t.  If child is a flat tree (a list), make all
        in list children of t.  Warning: if t has no children, but child does
        and child isNil then you can decide it is ok to move children to t via
        t.children = child.children; i.e., without copying the array.  Just
        make sure that this is consistent with have the user will build
        ASTs.
        N(   R   R+   (   R   RA   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR+     s    c         C   s   t  | t  o |  i |  } n | d j o | St  | t  p |  i |  } n | i   oM | i   } | d j o | i d  } q | d j o t	 d   q n | i
 |  | S(   s  
        If oldRoot is a nil root, just copy or move the children to newRoot.
        If not a nil root, make oldRoot a child of newRoot.

          old=^(nil a b c), new=r yields ^(r a b c)
          old=^(a b c), new=r yields ^(r ^(a b c))

        If newRoot is a nil-rooted single child tree, use the single
        child as the new root node.

          old=^(nil a b c), new=^(nil r) yields ^(r a b c)
          old=^(a b c), new=^(nil r) yields ^(r ^(a b c))

        If oldRoot was null, it's ok, just return newRoot (even if isNil).

          old=null, new=r yields r
          old=null, new=^(nil r) yields ^(nil r)

        Return newRoot.  Throw an exception if newRoot is not a
        simple node or nil root with a single child node--it must be a root
        node.  If newRoot is ^(nil x) return x as newRoot.

        Be advised that it's ok for newRoot to point at oldRoot's
        children; i.e., you don't have to copy the list.  We are
        constructing these nodes so we should have this control for
        efficiency.
        i   i    s   more than one node as rootN(   Ra   R   Rh   R   t
   CommonTreeR?   R1   R   R   R   R+   (   R   RJ   RK   t   nc(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRL     s    c         C   s   | d j	 on | i   oa | i   d j o
 d } q{ | i   d j o- | i d  } | i d  | i d  q{ n | S(   s'   Transform ^(nil x) to x and nil to nulli    i   iN(   R   R1   R   R   R"   R)   (   R   RM   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRN   D  s    
c         C   s   t  | t t f  p t t |  i  t  | t  p t t |  i  | d  j p# t  | t  p t t |  i  |  i	 |  } | | _ | d  j	 o | | _
 n |  i |  } | S(   N(   Ra   Rb   Rc   t   AssertionErrorRV   R   R   R   Rd   t   createTokenRS   R?   (   R   RQ   RR   RS   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRT   T  s    )#0	c         C   s   t  | t t f  p t t |  i  t  | t  p  | d  j p t t |  i  |  i d | d |  } |  i	 |  } | S(   NRQ   RS   (
   Ra   Rb   Rc   R   RV   R   Rd   R   R   R?   (   R   RQ   RS   RR   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRU   a  s
    )0c         C   s
   | i    S(   N(   R7   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR7   j  s    c         C   s   t  d   d  S(   Ns!   don't know enough about Tree node(   R   (   R   R!   RV   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRW   n  s    c         C   s
   | i    S(   N(   R8   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR8   r  s    c         C   s   t  d   d  S(   Ns!   don't know enough about Tree node(   R   (   R   R!   RS   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRX   v  s    c         C   s   | i  |  S(   N(   R   (   R   R!   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   z  s    c         C   s   | i  | |  d  S(   N(   R,   (   R   R!   R   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR,   ~  s    c         C   s   | i  |  S(   N(   R-   (   R   R!   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR-     s    c         C   s
   | i    S(   N(   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s
   t  |  S(   N(   t   hash(   R   RO   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRP     s    c         C   s
   t   d S(   s  
        Tell me how to create a token for use with imaginary token nodes.
        For example, there is probably no input symbol associated with imaginary
        token DECL, but you need to create it as a payload or whatever for
        the DECL node as in ^(DECL type ID).

        If you care what the token payload objects' type is, you should
        override this method and any other createToken variant.
        N(   R   (   R   RR   RQ   RS   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    N(   R   R   R   RC   RH   R1   R   RB   R+   RL   RN   RT   RU   R7   RW   R8   RX   R   R,   R-   R   RP   R   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s(   					7												R   c           B   s  e  Z d  Z d   Z d   Z d   Z d   Z d   Z e e  Z	 d   Z
 e e
  Z d   Z e e  Z d   Z e e  Z d	   Z d
   Z e e e  Z d   Z d   Z e e e  Z d   Z d   Z d   Z d   Z d   Z d   Z e Z d   Z RS(   sq  @brief A tree node that is wrapper for a Token object.

    After 3.0 release
    while building tree rewrite stuff, it became clear that computing
    parent and child index is very difficult and cumbersome.  Better to
    spend the space in every tree node.  If you don't want these extra
    fields, it's easy to cut them out in your own BaseTree subclass.
    
    c         C   s   t  i |   d |  _ d |  _ d  |  _ d |  _ | d  j o d  |  _ nx t | t	  o( | i |  _ | i |  _ | i |  _ n@ | d  j p t | t
  o | |  _ n t t |  i   d  S(   Ni(   Ri   R   t
   startIndext	   stopIndexR   R]   Rk   t   tokenRa   R   R   Re   RV   R   (   R   R>   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    				c         C   s   |  i  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRY     s    c         C   s
   t  |   S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR6     s    c         C   s   |  i  d  j S(   N(   R   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR1     s    c         C   s"   |  i  d  j o t S|  i  i   S(   N(   R   R   R   R7   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR7     s    c         C   s   |  i  d  j o d  S|  i  i S(   N(   R   R   RS   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR8     s    c         C   s\   |  i  d  j p |  i  i   d j o) |  i   o |  i d  i   Sd Sn |  i  i   S(   Ni    (   R   R   R9   R   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR9     s
    &c         C   s`   |  i  d  j p |  i  i   d j o) |  i   o |  i d  i   Sd Sn |  i  i   Sd  S(   Nii    (   R   R   R:   R   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR:      s
    &c         C   s5   |  i  d j o |  i d  j	 o |  i i   S|  i  S(   Ni(   R   R   R   t   getTokenIndex(   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR2     s     c         C   s   | |  _  d  S(   N(   R   (   R   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR3     s    c         C   s5   |  i  d j o |  i d  j	 o |  i i   S|  i  S(   Ni(   R   R   R   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR4     s     c         C   s   | |  _  d  S(   N(   R   (   R   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR5     s    c         C   s   |  i  d j oB |  i d j  p |  i d j  o |  i i   |  _ |  _ n d Sx |  i  D] } | i   q\ W|  i d j o |  i d j o d S|  i  o< |  i  d } |  i  d } | i   |  _ | i   |  _ n d S(   s   For every node in this subtree, make sure it's start/stop token's
        are set.  Walk depth first, visit bottom up.  Only updates nodes
        with at least one token index < 0.
        i    Ni(	   Rj   R   R   R   R   R   t   setUnknownTokenBoundariesR2   R4   (   R   RI   t
   firstChildt	   lastChild(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   %  s     
  
c         C   s   |  i  S(   N(   Rk   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR'   ?  s    c         C   s   | |  _  d  S(   N(   Rk   (   R   Rt   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR)   D  s    c         C   s   |  i  S(   N(   R]   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR    I  s    c         C   s   | |  _  d  S(   N(   R]   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR"   N  s    c         C   s4   |  i    o d S|  i   t j o d S|  i i S(   NRC   s   <errornode>(   R1   R7   R   R   RS   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR<   S  s
    c         C   s   |  i  p |  i   Sd } |  i   p | d |  i   7} n | d i g  } |  i  D] } | | i   qW ~  7} |  i   p | d 7} n | S(   NR   s   (%s R   R   (   Rj   R<   R1   Rf   R;   (   R   t   rett   _[1]RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR;   `  s    
7(   R   R   R   R   RY   R6   R1   R7   t   propertyRV   R8   RS   R9   t   lineR:   t   charPositionInLineR2   R3   t   tokenStartIndexR4   R5   t   tokenStopIndexR   R'   R)   R    R"   R<   t   __str__R;   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s6   										
											R   c           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s9   A node representing erroneous token range in token streamc         C   s{   t  i |  d   | d  j p, | i   | i   j  o | i   t j o
 | } n | |  _ | |  _ | |  _ | |  _	 d  S(   N(
   R   R   R   R   R7   R   RD   RE   RF   t   trappedException(   R   RD   RE   RF   RG   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   v  s    
			c         C   s   t  S(   N(   R|   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR1     s    c         C   s   t  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR7     s    c         C   s   t  |  i t  o` |  i i   } |  i i   } |  i i   t j o |  i i   } n |  i i	 | |  } n9 t  |  i t
  o |  i i	 |  i |  i  } n d } | S(   Ns	   <unknown>(   Ra   RE   R   R   RF   R7   R   RD   t   sizeR<   R   (   R   R   t   jt   badText(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR8     s    c         C   s   t  |  i t  o d t |  i i    d St  |  i t  o* d t |  i i    d |  i   d St  |  i t  o' d t |  i i	  d |  i   d St  |  i t
  o' d t |  i i	  d |  i   d Sd |  i   d S(   Ns   <missing type: t   >s   <extraneous: s	   , resync=s   <mismatched token: s   <unexpected: s   <error: (   Ra   R   R   t   strt   getMissingTypeR   t   getUnexpectedTokenR8   R   R   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR<     s    *''(   R   R   R   R   R1   R7   R8   R<   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   s  s   				t   CommonTreeAdaptorc           B   s   e  Z d  Z d   Z d   Z d d d d  Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s'  
    @brief A TreeAdaptor that works with any Tree implementation.
    
    It provides
    really just factory methods; all the work is done by BaseTreeAdaptor.
    If you would like to have different tokens created than ClassicToken
    objects, you need to override this and then set the parser tree adaptor to
    use your subclass.

    To get your parser to build nodes of a different type, override
    create(Token), errorNode(), and to be safe, YourTreeClass.dupNode().
    dupNode is called to duplicate nodes during rewrite operations.
    c         C   s   | d j o d S| i   S(   s   
        Duplicate a node.  This is part of the factory;
        override if you want another kind of node to be built.

        I could use reflection to prevent having to override this
        but reflection is slow.
        N(   R   R6   (   R   R@   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR6     s    	c         C   s
   t  |  S(   N(   R   (   R   R>   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR?     s    c         C   s.   | d j	 o t d |  St d | d |  S(   s  
        Tell me how to create a token for use with imaginary token nodes.
        For example, there is probably no input symbol associated with imaginary
        token DECL, but you need to create it as a payload or whatever for
        the DECL node as in ^(DECL type ID).

        If you care what the token payload objects' type is, you should
        override this method and any other createToken variant.
        t   oldTokenRV   RS   N(   R   R   (   R   RR   RQ   RS   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   sp   | d j o d Sd } d } | d j	 o | i } n | d j	 o | i } n | i |  | i |  d S(   s  
        Track start/stop token for subtree root created for a rule.
        Only works with Tree nodes.  For rules that match nothing,
        seems like this will yield start=i and stop=i-1 in a nil node.
        Might be useful info so I'll not force to be i..i.
        Ni    (   R   R(   R3   R5   (   R   R!   RZ   R[   RE   RF   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR\     s    c         C   s   | d  j o d S| i   S(   Ni(   R   R2   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR2   	  s    c         C   s   | d  j o d S| i   S(   Ni(   R   R4   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR4     s    c         C   s   | d  j o d  S| i   S(   N(   R   R8   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR8     s    c         C   s   | d  j o t S| i   S(   N(   R   R   R7   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR7     s    c         C   s   t  | t  o | i   Sd S(   s   
        What is the Token associated with this node?  If
        you are not using CommonTree, then you must
        override this in your own adaptor.
        N(   Ra   R   RY   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyRY   "  s    c         C   s   | d  j o d  S| i |  S(   N(   R   R   (   R   R!   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   /  s    c         C   s   | d  j o d S| i   S(   Ni    (   R   R   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   5  s    c         C   s
   | i    S(   N(   R    (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR    ;  s    c         C   s   | i  |  d  S(   N(   R"   (   R   R!   R]   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR"   ?  s    c         C   s   | d  j o d S| i   S(   Ni    (   R   R'   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR'   C  s    c         C   s   | i  |  d  S(   N(   R)   (   R   R!   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR)   I  s    c         C   s(   | d  j	 o | i | | |  n d  S(   N(   R   R0   (   R   R]   R.   R/   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR0   M  s    N(   R   R   R   R6   R?   R   R   R\   R2   R4   R8   R7   RY   R   R   R    R"   R'   R)   R0   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s"   														t   TreeNodeStreamc           B   sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   sT   @brief A stream of tree nodes

    It accessing nodes from a tree of some kind.
    c         C   s
   t   d S(   s   Get a tree node at an absolute index i; 0..n-1.
        If you don't want to buffer up nodes, then this method makes no
        sense for you.
        N(   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getl  s    c         C   s
   t   d S(   sL  
        Get tree node at current input pointer + i ahead where i=1 is next node.
        i<0 indicates nodes in the past.  So LT(-1) is previous node, but
        implementations are not required to provide results for k < -1.
        LT(0) is undefined.  For i>=n, return null.
        Return null for LT(0) and any index that results in an absolute address
        that is negative.

        This is analogus to the LT() method of the TokenStream, but this
        returns a tree node instead of a token.  Makes code gen identical
        for both parser and tree grammars. :)
        N(   R   (   R   t   k(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   LTu  s    c         C   s
   t   d S(   s   
        Where is this stream pulling nodes from?  This is not the name, but
        the object that provides node objects.
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getTreeSource  s    c         C   s
   t   d S(   s!  
        If the tree associated with this stream was created from a TokenStream,
        you can specify it here.  Used to do rule $text attribute in tree
        parser.  Optional unless you use tree parser rule text attribute
        or output=template and rewrite=true options.
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getTokenStream  s    c         C   s
   t   d S(   sx   
        What adaptor can tell me how to interpret/navigate nodes and
        trees.  E.g., get text of a node.
        N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getTreeAdaptor  s    c         C   s
   t   d S(   sG  
        As we flatten the tree, we use UP, DOWN nodes to represent
        the tree structure.  When debugging we need unique nodes
        so we have to instantiate new ones.  When doing normal tree
        parsing, it's slow and a waste of memory to create unique
        navigation nodes.  Default should be false;
        N(   R   (   R   t   uniqueNavigationNodes(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setUniqueNavigationNodes  s    	c         C   s
   t   d S(   sK  
        Return the text of all nodes from start to stop, inclusive.
        If the stream does not buffer all the nodes then it can still
        walk recursively from start until stop.  You can always return
        null or "" too, but users should not access $ruleLabel.text in
        an action of course in that case.
        N(   R   (   R   RE   RF   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR<     s    	c         C   s
   t   d S(   s*  
 	Replace from start to stop child index of parent with t, which might
        be a list.  Number of children may be different
        after this call.  The stream is notified because it is walking the
        tree and might need to know you are monkeying with the underlying
        tree.  Also, it might be able to modify the node stream to avoid
        restreaming for future phases.

        If parent is null, don't do anything; must be at root of overall tree.
        Can't replace whatever points to the parent externally.  Do nothing.
        N(   R   (   R   R]   R.   R/   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR0     s    (   R   R   R   R   R   R   R   R   R   R<   R0   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   b  s   										t   CommonTreeNodeStreamc           B   s+  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d  d  Z d   Z d  d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d   Z" RS(!   s  @brief A buffered stream of tree nodes.

    Nodes can be from a tree of ANY kind.

    This node stream sucks all nodes out of the tree specified in
    the constructor during construction and makes pointers into
    the tree using an array of Object pointers. The stream necessarily
    includes pointers to DOWN and UP and EOF nodes.

    This stream knows how to mark/release for backtracking.

    This stream is most suitable for tree interpreters that need to
    jump around a lot or for tree parsers requiring speed (at cost of memory).
    There is some duplicated functionality here with UnBufferedTreeNodeStream
    but just in bookkeeping, not tree walking etc...

    @see UnBufferedTreeNodeStream
    c         G   s  t  i |   t |  d j o/ t   } | d } d  } d  } d  } d  } n t |  d j o0 | d } | d } d  } d  } d  } d  } n t |  d j o_ | d } | d }	 | d }
 | i } | i } | i |	 |
 !} | i } | i	 } | i
 } n t d   | d  j	 o | |  _ n | i t d  |  _ | d  j	 o | |  _	 n | i t d  |  _	 | d  j	 o | |  _
 n | i t d  |  _
 | d  j	 o | |  _ n
 g  |  _ | |  _ d  |  _ | |  _ t |  _ d	 |  _ d  |  _ g  |  _ d  S(
   Ni   i    i   i   s   Invalid argumentsR   R    R   i(   R   R   R`   R   R   t   adaptorRM   t   nodest   downt   upt   eofRe   RU   R   R    R   t   tokensR|   R   t   pt
   lastMarkert   calls(   R   Rg   R   RA   R   R   R   R   R]   RE   RF   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     sZ    	







				
							c         C   s   |  i  |  i  d |  _ d S(   s}   Walk tree with depth-first-search and fill nodes buffer.
        Don't do DOWN, UP nodes if its a list (t is isNil).
        i    N(   t   _fillBufferRM   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt
   fillBuffer:  s    c         C   s   |  i  i |  } | p |  i i |  n |  i  i |  } | o | d j o |  i t  n x0 t |  D]" } |  i |  i  i	 | |   qr W| o | d j o |  i t
  n d  S(   Ni    (   R   R1   R   Rr   R   t   addNavigationNodeR   R   R   R   R    (   R   R!   RC   t   nt   c(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   C  s      c         C   sT   |  i  d j o |  i   n x/ t |  i  D] \ } } | | j o | Sq. Wd S(   sW   What is the stream index for node? 0..n-1
        Return -1 if node not found.
        i(   R   R   Rq   R   (   R   RO   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getNodeIndexW  s     	c         C   s   d } | t j o3 |  i   o |  i i t d  } qu |  i } n0 |  i   o |  i i t d  } n
 |  i } |  i i	 |  d S(   s   
        As we flatten the tree, we use UP, DOWN nodes to represent
        the tree structure.  When debugging we need unique nodes
        so instantiate new ones when uniqueNavigationNodes is true.
        R   R    N(
   R   R   t   hasUniqueNavigationNodesR   RU   R   R    R   R   Rr   (   R   R#   t   navNode(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   f  s    	c         C   s)   |  i  d j o |  i   n |  i | S(   Ni(   R   R   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   |  i  d j o |  i   n | d j o d  S| d j  o |  i |  S|  i  | d t |  i  j o |  i S|  i |  i  | d S(   Nii    i   (   R   R   R   t   LBR`   R   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    !c         C   s   |  i  d  S(   Ni   (   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getCurrentSymbol  s    c         C   s=   | d j o d S|  i | d j  o d S|  i |  i | S(   s   Look backwards k nodesi    N(   R   R   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s
    c         C   s   |  i  S(   N(   RM   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   |  i    i   S(   N(   R   t   getSourceName(   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   |  i  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   setTokenStream  s    c         C   s   |  i  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   |  i  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s1   |  i  d j o |  i   n |  i  d 7_  d  S(   Nii   (   R   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   consume  s    c         C   s   |  i  i |  i |   S(   N(   R   R7   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   LA  s    c         C   s4   |  i  d j o |  i   n |  i   |  _ |  i S(   Ni(   R   R   R(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   mark  s    c         C   s   d  S(   N(    (   R   t   marker(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   release  s    c         C   s   |  i  S(   N(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR(     s    c         C   s+   | d  j o |  i } n |  i |  d  S(   N(   R   R   t   seek(   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   rewind  s    c         C   s+   |  i  d j o |  i   n | |  _  d  S(   Ni(   R   R   (   R   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s$   |  i  i |  i  |  i |  d S(   sj   
        Make stream jump to a new location, saving old location.
        Switch back with pop().
        N(   R   Rr   R   R   (   R   R(   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   push  s    c         C   s#   |  i  i d  } |  i |  | S(   sx   
        Seek back to previous index saved during last push() call.
        Return top of stack (return index).
        i(   R   t   popR   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   d |  _  d |  _ g  |  _ d  S(   Ni    (   R   R   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   reset  s    		c         C   s+   |  i  d j o |  i   n t |  i  S(   Ni(   R   R   R`   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   
  s    c         C   s.   | d  j	 o |  i i | | | |  n d  S(   N(   R   R   R0   (   R   R]   R.   R/   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR0     s    	c         C   s[   |  i  d j o |  i   n d i g  } |  i D] } | t |  i i |   q2 ~  S(   s3   Used for testing, just return the token type streamiR   (   R   R   Rf   R   R   R   R7   (   R   R   RO   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c   	      C   s  | d  j p | d  j o d  S|  i d j o |  i   n |  i d  j	 o |  i i |  } |  i i |  } |  i i |  t j o |  i i |  } n. |  i i |  t	 j o |  i
   d } n |  i i | |  Sd \ } } x/ t |  i  D] \ } } | | j o Pq q Wg  } |  i | } xo | | j oa |  i i |  } | d  j o d |  i i |  } n | i |  | d 7} |  i | } q5W|  i i |  } | d  j o d |  i i |  } n | i |  d i |  S(   Nii   i    R   i   R   (   i    N(   R   R   R   R   R   R2   R4   R7   R    R   R   R<   Rq   R   R8   Rr   Rf   (	   R   RE   RF   t   beginTokenIndext   endTokenIndexR   R!   R   RS   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR<   %  s@     	 
c         c   s;   |  i  d j o |  i   n x |  i D] } | Vq( Wd  S(   Ni(   R   R   R   (   R   RO   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   __iter__b  s
    
 N(#   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R(   R   R   R   R   R   R   R0   R   R<   R   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s@   	Z																							
							=t
   TreeParserc           B   s   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d Z d	 Z e i e  Z e i e  Z d d d d
  Z e d    Z e d    Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s   @brief Baseclass for generated tree parsers.
    
    A parser for a stream of tree nodes.  "tree grammars" result in a subclass
    of this.  All the error reporting and recovery is shared with Parser via
    the BaseRecognizer superclass.
    c         C   s*   t  i |  |  d  |  _ |  i |  d  S(   N(   R   R   R   RD   t   setTreeNodeStream(   R   RD   t   state(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   x  s    	c         C   s5   t  i |   |  i d  j	 o |  i i d  n d  S(   Ni    (   R   R   RD   R   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   | |  _  d S(   s   Set the input streamN(   RD   (   R   RD   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   |  i  S(   N(   RD   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getTreeNodeStream  s    c         C   s   |  i  i   S(   N(   RD   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s    c         C   s   | i  d  S(   Ni   (   R   (   R   RD   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getCurrentInputSymbol  s    c         C   s.   d |  i  | d } t t d | d |   S(   Ns	   <missing R   RV   RS   (   t
   tokenNamesR   R   (   R   RD   t   et   expectedTokenTypet   followt	   tokenText(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getMissingSymbol  s    s   .*[^.]\.\.[^.].*s   .*\.\.\.\s+\.\.\..*c         C   s.   t  |  i i   |  i   |  i i d  |  S(   s  Check if current node in input has a context.

        Context means sequence of nodes towards root of tree.  For example,
        you might say context is "MULT" which means my parent must be MULT.
        "CLASS VARDEF" says current node must be child of a VARDEF and whose
        parent is a CLASS node.  You can use "..." to mean zero-or-more nodes.
        "METHOD ... VARDEF" means my parent is VARDEF and somewhere above
        that is a METHOD node.  The first node in the context is not
        necessarily the root.  The context matcher stops matching and returns
        true when it runs out of context.  There is no way to force the first
        node to be the root. 
        i   (   t
   _inContextRD   R   t   getTokenNamesR   (   R   t   contextR   t	   tokenNameR!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt	   inContext  s    c   
      C   s  |  i  i |  o t d   n |  i i |  o t d   n | i d d  } | i   } | i   } t |  d } | i |  } x | d j o | d j	 o | | d j o^ | d j o t
 S| | d } |  i | | | |  } | d j o t S| } | d 8} n | | i |  }	 |	 | | j o t S| d 8} | i |  } q W| d j o | d j o t St
 S(   sd   The worker for inContext.

        It's static and full of parameters for testing purposes.
        s   invalid syntax: ..s   invalid syntax: ... ...s   ...s    ... i   i    N(   t   dotdotPatternt   matchRp   t   doubleEtcPatternt   replacet   stript   splitR`   R    R   t   Truet   _getAncestorR|   R7   (
   t   clsR   R   R!   R   R   t   nit   goalt   ancestort   name(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s8     
c         C   sM   xF | d j	 o8 | |  i |  } | | j o | S|  i |  } q Wd S(   s   Helper for static inContext.N(   R   R7   R    (   R   R   R!   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR     s     c         C   s  t  |  i _ |  i i d  } |  i i   i |  d j o |  i i   d Sd } |  i i   i |  } x | t	 j o | t
 j o
 | d j oq |  i i   |  i i d  } |  i i   i |  } | t j o | d 7} qp | t
 j o | d 8} qp qp W|  i i   d S(   s   
        Match '.' in tree parser has special meaning.  Skip node or
        entire tree if node has children.  If children, scan until
        corresponding UP node.
        i   i    N(   R|   t   _statet   errorRecoveryRD   R   R   R   R   R7   R   R    R   (   R   t   ignoret   lookt   levelRQ   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   matchAny  s"     (c         C   s   t  | |   d S(   s   
        We have DOWN/UP nodes in the stream that have no line info; override.
        plus we want to alter the exception type. Don't try to recover
        from tree parser errors inline...
        N(   R
   (   R   RD   R#   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   mismatch	  s    c         C   s.   |  i    d d d g | i | i | i f S(   s   
        Prefix error message with the grammar name because message is
        always intended for the programmer because the parser built
        the input tree not the user.
        s   : node from %sline %s:%sR   s   after (   t   getGrammarFileNamet   approximateLineInfoR   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getErrorHeader	  s
    	c         C   s   t  |  t  ol | i i   } | i | i  | _ | i d j	 o4 t d | i	 | i  d | i
 | i   | _ q| n t i |  | |  S(   s   
        Tree parsers parse nodes they usually have a token object as
        payload. Set the exception token and do the default behavior.
        RV   RS   N(   Ra   R   RD   R   RY   RO   R   R   R   R7   R8   R   t   getErrorMessage(   R   R   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   )	  s     c         C   s&   t  i |  | | |  i i d   d  S(   Ni   (   R   t   traceInRD   R   (   R   t   ruleNamet	   ruleIndex(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   ;	  s    c         C   s&   t  i |  | | |  i i d   d  S(   Ni   (   R   t   traceOutRD   R   (   R   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   ?	  s    N(   R   R   R   R   R   R   R   R   R   R   R   t   dotdott	   doubleEtct   ret   compileR   R   R   t   classmethodR   t   staticmethodR   R   R   R   R   R   R   (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   p  s*   						1		
			t   TreeVisitorc           B   s)   e  Z d  Z d d  Z d d d  Z RS(   sR   Do a depth first walk of a tree, applying pre() and post() actions
    we go.
    c         C   s*   | d  j	 o | |  _ n t   |  _ d  S(   N(   R   R   R   (   R   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   N	  s    c         C   s   |  i  i |  } | d j	 o | o | |  } n xH t |  i  i |   D]. } |  i  i | |  } |  i | | |  qP W| d j	 o | o | |  } n | S(   s  Visit every node in tree t and trigger an action for each node
        before/after having visited all of its children.  Bottom up walk.
        Execute both actions even if t has no children.  Ignore return
        results from transforming children since they will have altered
        the child list of this node (their parent).  Return result of
        applying post action to this node.

        The Python version differs from the Java version by taking two
        callables 'pre_action' and 'post_action' instead of a class instance
        that wraps those methods. Those callables must accept a TreeNode as
        their single argument and return the (potentially transformed or
        replaced) TreeNode.
        N(   R   R1   R   t   xrangeR   R   t   visit(   R   R!   t
   pre_actiont   post_actionR1   Rt   RI   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR	  T	  s     N(   R   R   R   R   R   R	  (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  I	  s   t   RewriteRuleElementStreamc           B   sq   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z e Z d
   Z RS(   sU  @brief Internal helper class.
    
    A generic list of elements tracked in an alternative to be used in
    a -> rewrite rule.  We need to subclass to fill in the next() method,
    which returns either an AST node wrapped around a token payload or
    an existing subtree.

    Once you start next()ing, do not try to add more elements.  It will
    break the cursor tracking I believe.

    @see org.antlr.runtime.tree.RewriteRuleSubtreeStream
    @see org.antlr.runtime.tree.RewriteRuleTokenStream
    
    TODO: add mechanism to detect/puke on modification after reading from
    stream
    c         C   ss   d |  _  d  |  _ d  |  _ t |  _ | |  _ | |  _ t | t	 t
 f  o d  |  _ | |  _ n |  i |  d  S(   Ni    (   t   cursorR   t   singleElementt   elementsR|   t   dirtyR   R   Ra   t   listt   tuplet   add(   R   R   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   	  s    							c         C   s   d |  _  t |  _ d S(   s   
        Reset the condition of this stream so that it appears we have
        not consumed any of its elements.  Elements themselves are untouched.
        Once we reset the stream, any future use will need duplicates.  Set
        the dirty bit.
        i    N(   R  R   R  (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   	  s    	c         C   s   | d  j o d  S|  i d  j	 o |  i i |  d  S|  i d  j o | |  _ d  Sg  |  _ |  i i |  i  d  |  _ |  i i |  d  S(   N(   R   R  Rr   R  (   R   t   el(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  	  s    			c         C   s]   |  i  p) |  i t |   j o- t |   d j o |  i   } |  i |  S|  i   } | S(   s=  
        Return the next element in the stream.  If out of elements, throw
        an exception unless size()==1.  If size is 1, then return elements[0].
        
        Return a duplicate node/subtree if stream is out of elements and
        size==1. If we've already used the element, dup (dirty bit set).
        i   (   R  R  R`   t   _nextt   dup(   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   nextTree	  s    	
)c         C   s   t  |   d j o t |  i   n |  i t  |   j o7 t  |   d j o |  i |  i  St |  i   n |  i d j	 o  |  i d 7_ |  i |  i  S|  i |  i |  i  } |  i d 7_ | S(   s_  
        do the work of getting the next element, making sure that it's
        a tree node or subtree.  Deal with the optimization of single-
        element list versus list of size > 1.  Throw an exception
        if the stream is empty or we're out of elements and size>1.
        protected so you can override in a subclass if necessary.
        i    i   N(	   R`   R   R   R  t   toTreeR  R   R   R  (   R   t   o(    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  	  s    	c         C   s
   t   d S(   s'  
        When constructing trees, sometimes we need to dup a token or AST
        subtree.  Dup'ing a token means just creating another AST node
        around it.  For trees, you must call the adaptor.dupTree() unless
        the element is for a tree root; then it must be a node dup.
        N(   R   (   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  	  s    c         C   s   | S(   s   
        Ensure stream emits trees; tokens must be converted to AST nodes.
        AST nodes can be passed through unmolested.
        (    (   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  	
  s    c         C   sF   |  i  d  j	 o |  i d j  p& |  i d  j	 o |  i t |  i  j  S(   Ni   (   R  R   R  R  R`   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   hasNext
  s     c         C   s7   |  i  d  j	 o d S|  i d  j	 o t |  i  Sd S(   Ni   i    (   R  R   R  R`   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   
  s
    c         C   s   |  i  S(   s8   Deprecated. Directly access elementDescription attribute(   R   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getDescription&
  s    N(   R   R   R   R   R   R   R  R  R  R  R  R  R   t   __len__R  (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  x	  s   "										t   RewriteRuleTokenStreamc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   @brief Internal helper class.c         C   s   | S(   N(    (   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  /
  s    c         C   s   |  i    } |  i i |  S(   N(   R  R   R?   (   R   R!   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   nextNode5
  s    c         C   s
   |  i    S(   N(   R  (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt	   nextToken:
  s    c         C   s   t  d   d  S(   Ns'   dup can't be called for a token stream.(   Re   (   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  >
  s    (   R   R   R   R  R  R  R  (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  ,
  s
   			t   RewriteRuleSubtreeStreamc           B   s    e  Z d  Z d   Z d   Z RS(   s   @brief Internal helper class.c         C   s`   |  i  p) |  i t |   j o0 t |   d j o |  i   } |  i i |  S|  i   } | S(   s  
        Treat next element as a single node even if it's a subtree.
        This is used instead of next() when the result has to be a
        tree root node.  Also prevents us from duplicating recently-added
        children; e.g., ^(type ID)+ adds ID to type and then 2nd iteration
        must dup the type node, but ID has been added.

        Referencing a rule result twice is ok; dup entire tree as
        we can't be adding trees as root; e.g., expr expr.

        Hideous code duplication here with super.next().  Can't think of
        a proper way to refactor.  This needs to always call dup node
        and super.next() doesn't know which to call: dup node or dup tree.
        i   (   R  R  R`   R  R   R6   (   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  E
  s    
)c         C   s   |  i  i |  S(   N(   R   RB   (   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  b
  s    (   R   R   R   R  R  (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   B
  s   	t   RewriteRuleNodeStreamc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   
    Queues up nodes matched on left side of -> in a tree parser. This is
    the analog of RewriteRuleTokenStream for normal parsers. 
    c         C   s
   |  i    S(   N(   R  (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  m
  s    c         C   s   |  i  i |  S(   N(   R   R6   (   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  q
  s    c         C   s   t  d   d  S(   Ns&   dup can't be called for a node stream.(   Re   (   R   R  (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR  u
  s    (   R   R   R   R  R  R  (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR!  g
  s   		t   TreeRuleReturnScopec           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   
    This is identical to the ParserRuleReturnScope except that
    the start property is a tree nodes not Token object
    when you are parsing trees.  To be generic the tree node types
    have to be Object.
    c         C   s   d  |  _ d  |  _ d  S(   N(   R   RE   RA   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR   
  s    	c         C   s   |  i  S(   N(   RE   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getStart
  s    c         C   s   |  i  S(   N(   RA   (   R   (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   getTree
  s    (   R   R   R   R   R#  R$  (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyR"  {
  s   		(,   R   R  t   antlr3.constantsR    R   R   R   t   antlr3.recognizersR   R   t   antlr3.streamsR   t   antlr3.tokensR   R   R	   t   antlr3.exceptionsR
   R   R   R   R   R   R   R   R   t   objectR   R=   Ri   R   R   t   INVALID_NODER   R   R   R   R   R  R  R  R   R!  R"  (    (    (    s5   /mit/xavid/lib/python2.6/site-packages/antlr3/tree.pyt   <module>   s:   #"(  !Kj /%