InterpreterRuleContext class

This class extends ParserRuleContext by allowing the value of {@link #getRuleIndex} to be explicitly set for the context.

[ParserRuleContext] does not include field storage for the rule index since the context classes created by the code generator override the {@link #getRuleIndex} method to return the correct value for that context. Since the parser interpreter does not use the context classes generated for a parser, this class (with slightly more memory overhead per node) is used to provide equivalent functionality.

Inheritance

Constructors

InterpreterRuleContext(ParserRuleContext? parent, int invokingStateNumber, int ruleIndex)
Constructs a new InterpreterRuleContext with the specified parent, invoking state, and rule index.

Properties

altNumber int
For rule associated with this parse tree internal node, return the outer alternative number used to match the input. Default implementation does not compute nor store this alt num. Create a subclass of ParserRuleContext with backing field and set option contextSuperClass. to set it.
getter/setter pairinherited
childCount int
no setterinherited
children List<ParseTree>?
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. This is empty for parsing w/o tree constr. operation because we don't the need to track the details about how we parse this rule.
getter/setter pairinherited
exception RecognitionException<IntStream>?
The exception that forced this rule to return. If the rule successfully completed, this is null.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
invokingState int
What state invoked the rule associated with this context? The "return address" is the followState of invokingState If parent is null, this should be -1.
getter/setter pairinherited
isEmpty bool
A context is empty if there is no invoking state; meaning nobody call current context.
no setterinherited
parent ParserRuleContext?
Set the parent for this node.
covariantgetter/setter pairinherited
payload RuleContext
no setterinherited
ruleContext RuleContext
no setterinherited
ruleIndex int
getter/setter pairoverride-getter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sourceInterval Interval
satisfy the ParseTree / SyntaxTree interface
no setterinherited
start Token?
Get the initial/final token in this context. Note that the range from start to stop is inclusive, so for rules that do not consume anything (for example, zero length or error productions) this token may exceed stop.
getter/setter pairinherited
stop Token?
Get the initial/final token in this context. Note that the range from start to stop is inclusive, so for rules that do not consume anything (for example, zero length or error productions) this token may exceed stop.
getter/setter pairinherited
text String
Return the combined text of all child nodes. This method only considers tokens which have been added to the parse tree.
no setterinherited

Methods

accept<T>(ParseTreeVisitor<T> visitor) → T?
The ParseTreeVisitor needs a double dispatch method. */
inherited
addAnyChild<T extends ParseTree>(T t) → T
Add a parse tree node to this as a child. Works for internal and leaf nodes. Does not set parent link; other add methods must do that. Other addChild methods call this.
inherited
addChild(TerminalNode t) TerminalNode
Add a token leaf node child and force its parent to be this node. */
inherited
addErrorNode(ErrorNode errorNode) ErrorNode
Add an error node child and force its parent to be this node.
inherited
copyFrom(ParserRuleContext ctx) → void
COPY a ctx (I'm deliberately not using copy constructor) to avoid confusion with creating node with parent. Does not copy children (except error leaves).
inherited
depth() int
inherited
enterRule(ParseTreeListener listener) → void
inherited
exitRule(ParseTreeListener listener) → void
inherited
getChild<T>(int i) ParseTree?
inherited
getRuleContext<T extends ParserRuleContext>(int i) → T?
inherited
getRuleContexts<T extends ParserRuleContext>() List<T>
inherited
getToken(int ttype, int i) TerminalNode?
inherited
getTokens(int ttype) List<TerminalNode>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeLastChild() → void
Used by enterOuterAlt to toss out a RuleContext previously added as we entered a rule. If we have # label, we will need to remove generic ruleContext object.
inherited
toInfoString(Parser recognizer) String
Used for rule context info debugging during parse-time, not so much for ATN debugging */
inherited
toString({List<String>? ruleNames, Recognizer<ATNSimulator>? recog, RuleContext? stop}) String
A string representation of this object.
inherited
toStringTree({List<String>? ruleNames, Parser? parser}) String
Print out a whole tree, not just a node, in LISP format (root child1 .. childN). Print just a node if this is a leaf.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited