antlr3.tree.RewriteRuleSubtreeStream Class Reference

Internal helper class. More...

Inheritance diagram for antlr3.tree.RewriteRuleSubtreeStream:

Inheritance graph
[legend]
Collaboration diagram for antlr3.tree.RewriteRuleSubtreeStream:

Collaboration graph
[legend]

List of all members.

Public Member Functions

def nextNode
 Treat next element as a single node even if it's a subtree.
def dup
 When constructing trees, sometimes we need to dup a token or AST subtree.


Detailed Description

Internal helper class.

Definition at line 2745 of file tree.py.


Member Function Documentation

def antlr3.tree.RewriteRuleSubtreeStream.nextNode (   self  ) 

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.

Definition at line 2762 of file tree.py.

def antlr3.tree.RewriteRuleSubtreeStream.dup (   self,
  el 
)

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.

Reimplemented from antlr3.tree.RewriteRuleElementStream.

Definition at line 2777 of file tree.py.


The documentation for this class was generated from the following file:

Generated on Mon Nov 29 17:24:30 2010 for ANTLR Python API by  doxygen 1.5.5