public class ParserRuleContext extends RuleContext
| Modifier and Type | Field and Description |
|---|---|
java.util.List<ParseTree> |
children
If we are debugging or building a parse tree for a visitor,
we need to track all of the tokens and rule invocations associated
with this rule's context.
|
RecognitionException |
exception
The exception that forced this rule to return.
|
Token |
start
For debugging/tracing purposes, we want to track all of the nodes in
the ATN traversed by the parser for a particular rule.
|
Token |
stop
For debugging/tracing purposes, we want to track all of the nodes in
the ATN traversed by the parser for a particular rule.
|
EMPTY, invokingState, parent| Constructor and Description |
|---|
ParserRuleContext() |
ParserRuleContext(ParserRuleContext parent,
int invokingStateNumber) |
| Modifier and Type | Method and Description |
|---|---|
RuleContext |
addChild(RuleContext ruleInvocation) |
TerminalNode |
addChild(TerminalNode t)
Does not set parent link; other add methods do that
|
TerminalNode |
addChild(Token matchedToken) |
ErrorNode |
addErrorNode(Token badToken) |
void |
copyFrom(ParserRuleContext ctx)
COPY a ctx (I'm deliberately not using copy constructor)
|
void |
enterRule(ParseTreeListener listener) |
void |
exitRule(ParseTreeListener listener) |
<T extends ParseTree> |
getChild(java.lang.Class<? extends T> ctxType,
int i) |
ParseTree |
getChild(int i)
If there are children, get the
ith value indexed from 0. |
int |
getChildCount()
How many children are there? If there is none, then this
node represents a leaf node.
|
ParserRuleContext |
getParent()
The parent of this node.
|
<T extends ParserRuleContext> |
getRuleContext(java.lang.Class<? extends T> ctxType,
int i) |
<T extends ParserRuleContext> |
getRuleContexts(java.lang.Class<? extends T> ctxType) |
Interval |
getSourceInterval()
Return an
Interval indicating the index in the
TokenStream of the first and last token associated with this
subtree. |
Token |
getStart()
Get the initial token in this context.
|
Token |
getStop()
Get the final token in this context.
|
TerminalNode |
getToken(int ttype,
int i) |
java.util.List<TerminalNode> |
getTokens(int ttype) |
void |
removeLastChild()
Used by enterOuterAlt to toss out a RuleContext previously added as
we entered a rule.
|
java.lang.String |
toInfoString(Parser recognizer)
Used for rule context info debugging during parse-time, not so much for ATN debugging
|
accept, depth, getPayload, getRuleContext, getRuleIndex, getText, inspect, inspect, isEmpty, save, save, save, save, toString, toString, toString, toString, toString, toStringTree, toStringTree, toStringTreepublic java.util.List<ParseTree> children
public Token start
public Token stop
public RecognitionException exception
null.public ParserRuleContext()
public ParserRuleContext(ParserRuleContext parent, int invokingStateNumber)
public void copyFrom(ParserRuleContext ctx)
public void enterRule(ParseTreeListener listener)
public void exitRule(ParseTreeListener listener)
public TerminalNode addChild(TerminalNode t)
public RuleContext addChild(RuleContext ruleInvocation)
public void removeLastChild()
public TerminalNode addChild(Token matchedToken)
public ParserRuleContext getParent()
Treepublic ParseTree getChild(int i)
Treeith value indexed from 0.public <T extends ParseTree> T getChild(java.lang.Class<? extends T> ctxType, int i)
public TerminalNode getToken(int ttype, int i)
public java.util.List<TerminalNode> getTokens(int ttype)
public <T extends ParserRuleContext> T getRuleContext(java.lang.Class<? extends T> ctxType, int i)
public <T extends ParserRuleContext> java.util.List<T> getRuleContexts(java.lang.Class<? extends T> ctxType)
public int getChildCount()
TreegetChildCount in interface TreegetChildCount in class RuleContextpublic 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.
If source interval is unknown, this returns Interval.INVALID.
getSourceInterval in interface SyntaxTreegetSourceInterval in class RuleContextpublic Token getStart()
public Token getStop()
public java.lang.String toInfoString(Parser recognizer)