Top Fields Constructors Methods
org.antlr.runtime.tree

public Class RewriteRuleSubtreeStream

extends RewriteRuleElementStream
Class Inheritance
Imports
java.util.List

Field Summary

Inherited from org.antlr.runtime.tree.RewriteRuleElementStream:
adaptorcursordirtyelementDescriptionelementssingleElement

Constructor Summary

AccessConstructor and Description
public
RewriteRuleSubtreeStream(TreeAdaptor adaptor, String elementDescription)

public
RewriteRuleSubtreeStream(TreeAdaptor adaptor, String elementDescription, Object oneElement)

Create a stream with one element

public
RewriteRuleSubtreeStream(TreeAdaptor adaptor, String elementDescription, List<Object> elements)

Create a stream, but feed off an existing list

Method Summary

Modifier and TypeMethod and Description
protected Object
dup(Object el)

Implements abstract org.antlr.runtime.tree.RewriteRuleElementStream.dup.

When constructing trees, sometimes we need to dup a token or AST subtree.
public Object
nextNode()

Treat next element as a single node even if it's a subtree.

Inherited from org.antlr.runtime.tree.RewriteRuleElementStream:
_nextaddgetDescriptionhasNextnextTreeresetsizetoTree

Constructor Detail

RewriteRuleSubtreeStreamback to summary
public RewriteRuleSubtreeStream(TreeAdaptor adaptor, String elementDescription)
RewriteRuleSubtreeStreamback to summary
public RewriteRuleSubtreeStream(TreeAdaptor adaptor, String elementDescription, Object oneElement)

Create a stream with one element

RewriteRuleSubtreeStreamback to summary
public RewriteRuleSubtreeStream(TreeAdaptor adaptor, String elementDescription, List<Object> elements)

Create a stream, but feed off an existing list

Method Detail

dupback to summary
protected Object dup(Object el)

Implements abstract org.antlr.runtime.tree.RewriteRuleElementStream.dup.

Doc from org.antlr.runtime.tree.RewriteRuleElementStream.dup.

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.

Annotations
@Override
nextNodeback to summary
public 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.