Parser class abstract

This is all the parsing support code essentially; most of it is error recovery stuff. */

Inheritance

Constructors

Parser(TokenStream _input)

Properties

ATNWithBypassAlts ATN
The ATN with bypass alternatives is expensive to create so we create it lazily.
no setter
buildParseTree bool
Specifies whether or not the parser should construct a parse tree during the parsing process. The default value is true.
getter/setter pair
bypassAltsAtnCache ATN?
This field maps from the serialized ATN string to the deserialized ATN with bypass alternatives.
getter/setter pair
context ParserRuleContext?
The ParserRuleContext object for the currently executing rule. This is always non-null during the parsing process.
getter/setter pair
currentToken Token
Match needs to return the current input symbol, which gets put into the label for the associated token ref; e.g., x=ID.
no setter
dfaStrings List<String>
For debugging and other purposes.
no setter
errorHandler ErrorStrategy
The error handling strategy for the parser. The default value is a new instance of DefaultErrorStrategy.
getter/setter pair
errorListenerDispatch ErrorListener
no setterinherited
errorListeners List<ErrorListener>
no setterinherited
expectedTokens IntervalSet
Computes the set of input symbols which could follow the current parser state and context, as given by {@link #getState} and {@link #getContext}, respectively.
no setter
expectedTokensWithinCurrentRule IntervalSet
no setter
grammarFileName String
For debugging and other purposes, might want the grammar name. Have ANTLR generate an implementation for this method.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
inputStream TokenStream
covariantgetter/setter pairoverride
interpreter ParserATNSimulator?
The ATN interpreter used by the recognizer for prediction.
getter/setter pairinherited
matchedEOF bool
Indicates parser has match()ed EOF token. See {@link #exitRule()}. */
getter/setter pair
numberOfSyntaxErrors int
Gets the number of syntax errors reported during parsing. This value is incremented each time {@link #notifyErrorListeners} is called.
no setter
parseInfo ParseInfo?
If profiling during the parse/lex, this will return DecisionInfo records for each decision in recognizer in a ParseInfo object.
no setteroverride
parseListeners List<ParseTreeListener>?
no setter
precedence int
Get the precedence level for the top-most precedence rule.
no setter
ruleContext ParserRuleContext
no setter
ruleIndexMap Map<String, int>
Get a map from rule names to rule indexes.
no setterinherited
ruleInvocationStack List<String>
no setter
ruleNames List<String>
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serializedATN List<int>
If this recognizer was generated, it will have a serialized ATN representation of the grammar.
no setterinherited
sourceName String
no setter
state int
getter/setter pairinherited
tokenFactory TokenFactory<Token>
Tell our token source and error strategy about a new way to create tokens.
getter/setter pairoverride
tokenStream TokenStream
no setter
tokenTypeMap Map<String, int>
Get a map from token names to token types.
no setterinherited
trimParseTree bool
@return true if the {@link ParserRuleContext#children} list is trimmed using the default {@link Parser.TrimToSizeListener} during the parse process.
getter/setter pair
vocabulary Vocabulary
Get the vocabulary used by the recognizer.
no setterinherited

Methods

action(RuleContext? _localctx, int ruleIndex, int actionIndex) → void
inherited
addContextToParseTree() → void
addErrorListener(ErrorListener listener) → void
inherited
addParseListener(ParseTreeListener listener) → void
Registers listener to receive events during the parsing process.
compileParseTreePattern(String pattern, int patternRuleIndex, [Lexer? lexer]) ParseTreePattern
The preferred method of getting a tree pattern. For example, here's a sample use:
consume() Token
Consume and return the {@linkplain #getCurrentToken current symbol}.
createErrorNode(ParserRuleContext parent, Token t) ErrorNode
How to create an error node, given a token, associated with a parent. Typically, the error node to create is not a function of the parent.
createTerminalNode(ParserRuleContext parent, Token t) TerminalNode
How to create a token leaf node associated with a parent. Typically, the terminal node to create is not a function of the parent.
dumpDFA() → void
For debugging and other purposes. */
enterOuterAlt(ParserRuleContext localctx, int altNum) → void
enterRecursionRule(ParserRuleContext localctx, int state, int ruleIndex, int precedence) → void
enterRule(ParserRuleContext localctx, int state, int ruleIndex) → void
Always called by generated parsers upon entry to a rule. Access field {@link #_ctx} get the current context.
exitRule() → void
getATN() ATN
Get the ATN used by the recognizer for prediction.
inherited
getErrorHeader(RecognitionException<IntStream> e) String
What is the error header, normally line/character position information? */
inherited
getInvokingContext(int ruleIndex) ParserRuleContext?
getRuleIndex(String ruleName) int
Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found. */
getRuleInvocationStack([RuleContext? p]) List<String>
Return List<String> of the rule names in your parser instance leading up to a call to the current rule. You could override if you want more details such as the file/line info of where in the ATN a rule is invoked.
getTokenType(String tokenName) int
inherited
inContext(String context) bool
isExpectedToken(int symbol) bool
Checks whether or not symbol can follow the current state in the ATN. The behavior of this method is equivalent to the following, but is implemented such that the complete context-sensitive follow set does not need to be explicitly constructed.
isMatchedEOF() bool
isTrace() bool
Gets whether a TraceListener is registered as a parse listener for the parser.
match(int ttype) Token
Match current input symbol against ttype. If the symbol type matches, {@link ANTLRErrorStrategy#reportMatch} and {@link #consume} are called to complete the match process.
matchWildcard() Token
Match current input symbol as a wildcard. If the symbol type matches (i.e. has a value greater than 0), {@link ANTLRErrorStrategy#reportMatch} and {@link #consume} are called to complete the match process.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyErrorListeners(String msg, [Token? offendingToken, RecognitionException<IntStream>? e]) → void
precpred(RuleContext? localctx, int precedence) bool
override
pushNewRecursionContext(ParserRuleContext localctx, int state, int? ruleIndex) → void
Like {@link #enterRule} but for recursive rules. Make the current context the child of the incoming localctx.
removeErrorListener(ErrorListener listener) → void
inherited
removeErrorListeners() → void
inherited
removeParseListener(ParseTreeListener? listener) → void
Remove listener from the list of parse listeners.
removeParseListeners() → void
Remove all parse listeners.
reset([bool resetInput = true]) → void
reset the parser's state */
sempred(RuleContext? _localctx, int ruleIndex, int actionIndex) bool
inherited
setProfile(bool profile) → void
@since 4.3
setTokenStream(TokenStream input) → void
Set the token stream and reset the parser. */
setTrace(bool trace) → void
During a parse is sometimes useful to listen in on the rule entry and exit events as well as token matches. This is for quick and dirty debugging.
toString() String
A string representation of this object.
inherited
triggerEnterRuleEvent() → void
Notify any parse listeners of an enter rule event.
triggerExitRuleEvent() → void
Notify any parse listeners of an exit rule event.
unrollRecursionContexts(ParserRuleContext? _parentctx) → void

Operators

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