public class ParserRuleContext extends RuleContext
| Modifier and Type | Field and Description |
|---|---|
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 |
|---|---|
<T extends ParseTree> |
addAnyChild(T t)
Add a parse tree node to this as a child.
|
RuleContext |
addChild(RuleContext ruleInvocation) |
TerminalNode |
addChild(TerminalNode t)
Add a token leaf node child and force its parent to be this node.
|
TerminalNode |
addChild(Token matchedToken)
Deprecated.
|
ErrorNode |
addErrorNode(ErrorNode errorNode)
Add an error node child and force its parent to be this node.
|
ErrorNode |
addErrorNode(Token badToken)
Deprecated.
|
void |
copyFrom(ParserRuleContext ctx)
COPY a ctx (I'm deliberately not using copy constructor) to avoid
confusion with creating node with parent.
|
void |
enterRule(ParseTreeListener listener) |
void |
exitRule(ParseTreeListener listener) |
<T extends ParseTree> |
getChild(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(Class<? extends T> ctxType,
int i) |
<T extends ParserRuleContext> |
getRuleContexts(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) |
List<TerminalNode> |
getTokens(int ttype) |
void |
removeLastChild()
Used by enterOuterAlt to toss out a RuleContext previously added as
we entered a rule.
|
String |
toInfoString(Parser recognizer)
Used for rule context info debugging during parse-time, not so much for ATN debugging
|
accept, depth, getAltNumber, getPayload, getRuleContext, getRuleIndex, getText, isEmpty, setAltNumber, setParent, toString, toString, toString, toString, toString, toStringTree, toStringTree, toStringTreepublic 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 <T extends ParseTree> T addAnyChild(T t)
public RuleContext addChild(RuleContext ruleInvocation)
public TerminalNode addChild(TerminalNode t)
public ErrorNode addErrorNode(ErrorNode errorNode)
@Deprecated public TerminalNode addChild(Token matchedToken)
Parser.createTerminalNode(ParserRuleContext, Token). I'm leaving this
in for compatibility but the parser doesn't use this anymore.@Deprecated public ErrorNode addErrorNode(Token badToken)
Parser.createErrorNode(ParserRuleContext, Token). I'm leaving this
in for compatibility but the parser doesn't use this anymore.public void removeLastChild()
public ParserRuleContext getParent()
Treepublic ParseTree getChild(int i)
Treeith value indexed from 0.public TerminalNode getToken(int ttype, int i)
public List<TerminalNode> getTokens(int ttype)
public <T extends ParserRuleContext> T getRuleContext(Class<? extends T> ctxType, int i)
public <T extends ParserRuleContext> List<T> getRuleContexts(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 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 SyntaxTreegetSourceInterval in class RuleContextpublic Token getStart()
public Token getStop()
Copyright © 1992–2018 ANTLR. All rights reserved.