public class RuleContext extends Object implements RuleNode
ParserRuleContext| 限定符和类型 | 字段和说明 |
|---|---|
int |
invokingState
What state invoked the rule associated with this context?
|
RuleContext |
parent
What context invoked this rule?
|
| 构造器和说明 |
|---|
RuleContext() |
RuleContext(RuleContext parent,
int invokingState) |
| 限定符和类型 | 方法和说明 |
|---|---|
<T> T |
accept(ParseTreeVisitor<? extends T> visitor)
The
ParseTreeVisitor needs a double dispatch method. |
int |
depth() |
int |
getAltNumber()
For rule associated with this parse tree internal node, return
the outer alternative number used to match the input.
|
ParseTree |
getChild(int i)
If there are children, get the
ith value indexed from 0. |
static RuleContext |
getChildContext(RuleContext parent,
int invokingState) |
int |
getChildCount()
How many children are there?
|
RuleContext |
getParent()
The parent of this node.
|
RuleContext |
getPayload()
This method returns whatever object represents the data at this node.
|
RuleContext |
getRuleContext() |
int |
getRuleIndex() |
Interval |
getSourceInterval()
Return an
Interval indicating the index in the
TokenStream of the first and last token associated with this
subtree. |
String |
getText()
Return the combined text of all child nodes.
|
boolean |
isEmpty()
A context is empty if there is no invoking state; meaning nobody called
current context.
|
void |
setAltNumber(int altNumber)
Set the outer alternative number for this context node.
|
void |
setParent(RuleContext parent) |
String |
toString() |
String |
toString(List<String> ruleNames) |
String |
toString(List<String> ruleNames,
RuleContext stop) |
String |
toString(Recognizer<?,?> recog) |
String |
toString(Recognizer<?,?> recog,
RuleContext stop) |
String |
toStringTree()
Print out a whole tree, not just a node, in LISP format
(root child1 .. childN). |
String |
toStringTree(List<String> ruleNames)
Print out a whole tree, not just a node, in LISP format
(root child1 .. childN).
|
String |
toStringTree(Parser recog)
Print out a whole tree, not just a node, in LISP format
(root child1 .. childN).
|
public RuleContext parent
public int invokingState
public RuleContext()
public RuleContext(RuleContext parent, int invokingState)
public static RuleContext getChildContext(RuleContext parent, int invokingState)
public int depth()
public boolean isEmpty()
public Interval getSourceInterval()
SyntaxTreeInterval 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 在接口中 SyntaxTreepublic RuleContext getRuleContext()
getRuleContext 在接口中 RuleNodepublic RuleContext getParent()
Treepublic RuleContext getPayload()
TreeToken representing
a leaf node or a RuleContext object representing a rule
invocation. For abstract syntax trees (ASTs), this is a Token
object.getPayload 在接口中 Treepublic String getText()
Since tokens on hidden channels (e.g. whitespace or comments) are not added to the parse trees, they will not appear in the output of this method.
public int getRuleIndex()
public int getAltNumber()
public void setAltNumber(int altNumber)
public void setParent(RuleContext parent)
public ParseTree getChild(int i)
Treeith value indexed from 0.public int getChildCount()
TreegetChildCount 在接口中 Treepublic <T> T accept(ParseTreeVisitor<? extends T> visitor)
ParseTreeParseTreeVisitor needs a double dispatch method.public String toStringTree(@Nullable Parser recog)
toStringTree 在接口中 ParseTreepublic String toStringTree(@Nullable List<String> ruleNames)
public String toStringTree()
Tree(root child1 .. childN). Print just a node if this is a leaf.toStringTree 在接口中 Treepublic final String toString(@Nullable Recognizer<?,?> recog)
public String toString(@Nullable Recognizer<?,?> recog, @Nullable RuleContext stop)
public String toString(@Nullable List<String> ruleNames, @Nullable RuleContext stop)
Copyright © 1992–2022 Daniel Sun. All rights reserved.