public class ParserRuleContext extends RuleContext
Modifier and Type | Field and Description |
---|---|
int |
altNum
Set during parsing to identify which alt of rule parser is in.
|
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 which 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(Class<? extends T> ctxType,
int i) |
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.
|
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() |
Token |
getStop() |
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, getPayload, getRuleContext, getRuleIndex, getText, inspect, inspect, isEmpty, save, save, save, save, toString, toString, toString, toString, toString, toStringTree, toStringTree, toStringTree
public List<ParseTree> children
public Token start
public Token stop
public int altNum
public RecognitionException exception
null
.public ParserRuleContext()
public ParserRuleContext(@Nullable 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()
Tree
public ParseTree getChild(int i)
Tree
i
th 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()
Tree
getChildCount
in interface Tree
getChildCount
in class RuleContext
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.
If source interval is unknown, this returns Interval.INVALID
.getSourceInterval
in interface SyntaxTree
getSourceInterval
in class RuleContext
public Token getStart()
public Token getStop()
Copyright © 1992-2013 ANTLR. All Rights Reserved.