ParseTree
, SyntaxTree
, TerminalNode
, Tree
ErrorNodeImpl
public class TerminalNodeImpl extends Object implements TerminalNode
Constructor | Description |
---|---|
TerminalNodeImpl(Token symbol) |
Modifier and Type | Method | Description |
---|---|---|
<T> T |
accept(ParseTreeVisitor<? extends T> visitor) |
The
ParseTreeVisitor needs a double dispatch method. |
ParseTree |
getChild(int i) |
If there are children, get the
i th value indexed from 0. |
int |
getChildCount() |
How many children are there? If there is none, then this
node represents a leaf node.
|
ParseTree |
getParent() |
The parent of this node.
|
Token |
getPayload() |
This method returns whatever object represents the data at this note.
|
Interval |
getSourceInterval() |
Return an
Interval indicating the index in the
TokenStream of the first and last token associated with this
subtree. |
Token |
getSymbol() |
|
String |
getText() |
Return the combined text of all leaf nodes.
|
String |
toString() |
|
String |
toStringTree() |
Print out a whole tree, not just a node, in LISP format
(root child1 .. childN) . |
String |
toStringTree(Parser parser) |
Specialize toStringTree so that it can print out more information
based upon the parser.
|
public TerminalNodeImpl(Token symbol)
public ParseTree getChild(int i)
Tree
i
th value indexed from 0.public Token getSymbol()
getSymbol
in interface TerminalNode
public ParseTree getParent()
Tree
public Token getPayload()
Tree
Token
representing
a leaf node or a RuleContext
object representing a rule
invocation. For abstract syntax trees (ASTs), this is a Token
object.getPayload
in interface Tree
public Interval getSourceInterval()
SyntaxTree
Interval
indicating the index in the
TokenStream
of the first and last token associated with this
subtree. If this node is a leaf, then the interval represents a single
token and has interval i..i for token index i.
An interval of i..i-1 indicates an empty interval at position i in the input stream, where 0 <= i <= the size of the input token stream. Currently, the code base can only have i=0..n-1 but in concept one could have an empty interval after EOF.
If source interval is unknown, this returns Interval.INVALID
.
As a weird special case, the source interval for rules matched after EOF is unspecified.
getSourceInterval
in interface SyntaxTree
public int getChildCount()
Tree
getChildCount
in interface Tree
public <T> T accept(ParseTreeVisitor<? extends T> visitor)
ParseTree
ParseTreeVisitor
needs a double dispatch method.public String getText()
ParseTree
public String toStringTree(Parser parser)
ParseTree
toStringTree
in interface ParseTree
public String toStringTree()
Tree
(root child1 .. childN)
. Print just a node if this is a leaf.toStringTree
in interface Tree
Copyright © 1992–2018 ANTLR. All rights reserved.