org.antlr.runtime.tree
Class RewriteRuleSubtreeStream
java.lang.Object
org.antlr.runtime.tree.RewriteRuleElementStream
org.antlr.runtime.tree.RewriteRuleSubtreeStream
public class RewriteRuleSubtreeStream
- extends RewriteRuleElementStream
Method Summary |
protected java.lang.Object |
dup(java.lang.Object el)
When constructing trees, sometimes we need to dup a token or AST
subtree. |
java.lang.Object |
nextNode()
Treat next element as a single node even if it's a subtree. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RewriteRuleSubtreeStream
public RewriteRuleSubtreeStream(TreeAdaptor adaptor,
java.lang.String elementDescription)
RewriteRuleSubtreeStream
public RewriteRuleSubtreeStream(TreeAdaptor adaptor,
java.lang.String elementDescription,
java.lang.Object oneElement)
- Create a stream with one element
RewriteRuleSubtreeStream
public RewriteRuleSubtreeStream(TreeAdaptor adaptor,
java.lang.String elementDescription,
java.util.List elements)
- Create a stream, but feed off an existing list
nextNode
public java.lang.Object nextNode()
- 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.
dup
protected java.lang.Object dup(java.lang.Object el)
- Description copied from class:
RewriteRuleElementStream
- 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.
- Specified by:
dup
in class RewriteRuleElementStream
Copyright © 2013. All Rights Reserved.