antlr4 library

Classes

AbstractPredicateTransition
ActionTransition
AmbiguityInfo
This class represents profiling event information for an ambiguity. Ambiguities are decisions where a particular input resulted in an SLL conflict, followed by LL prediction also reaching a conflict state (indicating a true ambiguity in the grammar).
AND
A semantic context which is true whenever none of the contained contexts is false.
ArrayPredictionContext
ATN
ATNConfig
A tuple: (ATN state, predicted alt, syntactic, semantic context). The syntactic context is a graph-structured stack node whose path(s) to the root is the rule invocation(s) chain used to arrive at the state. The semantic context is the tree of semantic predicates encountered before reaching an ATN state.
ATNConfigSet
ATNDeserializationOptions
ATNDeserializer
ATNSimulator
ATNState
The following images show the relation of states and {@link ATNState#transitions} for various grammar constructs.
AtomTransition
TODO: make all transitions sets? no, should remove set edges */
BailErrorStrategy
This implementation of ANTLRErrorStrategy responds to syntax errors by immediately canceling the parse operation with a ParseCancellationException. The implementation ensures that the {@link ParserRuleContext#exception} field is set for all parse tree nodes that were not completed prior to encountering the error.
BaseErrorListener
BasicBlockStartState
BasicState
BlockEndState
Terminal node of a simple {@code (a|b|c)} block.
BlockStartState
BufferedTokenStream
This implementation of TokenStream loads tokens from a TokenSource on-demand, and places the tokens in a buffer to provide access to any previous token by index.
CharStream
A source of characters for an ANTLR lexer. */
Chunk
A chunk is either a token tag, a rule tag, or a span of literal text within a tree pattern.
CommonToken
CommonTokenFactory
This default implementation of TokenFactory creates CommonToken objects.
CommonTokenStream
This class extends BufferedTokenStream with functionality to filter token streams to tokens on a particular channel (tokens where {@link Token#getChannel} returns a particular value).
ConsoleErrorListener
ContextSensitivityInfo
This class represents profiling event information for a context sensitivity. Context sensitivities are decisions where a particular input resulted in an SLL conflict, but LL prediction produced a single unique alternative.
DecisionEventInfo
This is the base class for gathering detailed information about prediction events which occur during parsing.
DecisionInfo
This class contains profiling gathered for a particular decision.
DecisionState
DefaultErrorStrategy
This is the default implementation of ANTLRErrorStrategy used for error reporting and recovery in ANTLR parsers.
DFA
DFAState
A DFA state represents a set of possible ATN configurations. As Aho, Sethi, Ullman p. 117 says "The DFA uses its state to keep track of all possible states the ATN can be in after reading each input symbol. That is to say, after reading input a1a2..an, the DFA is in a state that represents the subset T of the states of the ATN that are reachable from the ATN's start state along some path labeled a1a2..an." In conventional NFA→DFA conversion, therefore, the subset T would be a bitset representing the set of states the ATN could be in. We need to track the alt predicted by each state as well, however. More importantly, we need to maintain a stack of states, tracking the closure operations as they jump from rule to rule, emulating rule invocations (method calls). I have to add a stack to simulate the proper lookahead sequences for the underlying LL grammar from which the ATN was derived.
DiagnosticErrorListener
This implementation of ANTLRErrorListener can be used to identify certain potential correctness and performance problems in grammars. "Reports" are made by calling {@link Parser#notifyErrorListeners} with the appropriate message.
EmptyPredictionContext
EmptySemanticContext
EpsilonTransition
ErrorInfo
This class represents profiling event information for a syntax error identified during prediction. Syntax errors occur when the prediction algorithm is unable to identify an alternative which would lead to a successful parse.
ErrorListener
ErrorNode
ErrorNodeImpl
Represents a token that was consumed during resynchronization rather than during a valid match operation. For example, we will create this kind of a node during single token insertion and deletion as well as during "consume until error recovery set" upon no viable alternative exceptions.
ErrorStrategy
The interface for defining strategies to deal with syntax errors encountered during a parse by ANTLR-generated parsers. We distinguish between three different kinds of errors:
InputStream
InterpreterRuleContext
This class extends ParserRuleContext by allowing the value of {@link #getRuleIndex} to be explicitly set for the context.
Interval
An immutable inclusive interval a..b */
IntervalSet
This class implements the IntervalSet backed by a sorted array of non-overlapping intervals. It is particularly efficient for representing large collections of numbers, where the majority of elements appear as part of a sequential range of numbers that are all part of the set. For example, the set { 1, 2, 3, 4, 7, 8 } may be represented as { 1, 4, 7, 8 }.
IntStream
A simple stream of symbols whose values are represented as integers. This interface provides marked ranges with support for a minimum level of buffering necessary to implement arbitrary lookahead during prediction. For more information on marked ranges, see {@link #mark}.
Lexer
LexerActionExecutor
Represents an executor for a sequence of lexer actions which traversed during the matching operation of a lexer rule (token).
LexerATNConfig
LexerATNSimulator
"dup" of ParserInterpreter */
ListTokenSource
Provides an implementation of TokenSource as a wrapper around a list of Token objects.
LookaheadEventInfo
This class represents profiling event information for tracking the lookahead depth required in order to make a prediction.
LoopEndState
Mark the end of a * or + loop.
MultiMap<K, V>
NotSetTransition
Operator
This is the base class for semantic context "operators", which operate on a collection of semantic context "operands".
OR
A semantic context which is true whenever at least one of the contained contexts is true.
OrderedATNConfigSet
Pair<A, B>
ParseInfo
This class provides access to specific and aggregate statistics gathered during profiling of a parser.
Parser
This is all the parsing support code essentially; most of it is error recovery stuff. */
ParserATNSimulator
The embodiment of the adaptive LL(), ALL(), parsing strategy.
ParserRuleContext
A rule invocation record for parsing.
ParseTree
ParseTreeListener
ParseTreeMatch
Represents the result of matching a ParseTree against a tree pattern.
ParseTreePattern
A pattern like {@code
ParseTreePatternMatcher
A tree pattern matching mechanism for ANTLR ParseTrees.
ParseTreeVisitor<T>
ParseTreeWalker
PlusBlockStartState
Start of {@code (A|B|...)+} loop. Technically a decision state, but we don't use for code generation; somebody might need it, so I'm defining it for completeness. In reality, the PlusLoopbackState node is the real decision-making note for {@code A+}.
PlusLoopbackState
Decision state for {@code A+} and {@code (A|B)+}. It has two transitions: one to the loop back to start of the block and one to exit.
PrecedencePredicate
PrecedencePredicateTransition
Predicate
PredicateEvalInfo
This class represents profiling event information for semantic predicate evaluations which occur during prediction.
PredicateTransition
PredictionContext
PredictionContextCache
Used to cache PredictionContext objects. Its used for the shared context cash associated with contexts in DFA states. This cache can be used for both lexers and parsers.
PredPrediction
Map a predicate to a predicted alternative. */
ProfilingATNSimulator
ProxyErrorListener
This implementation of ErrorListener dispatches all calls to a collection of delegate listeners. This reduces the effort required to support multiple listeners.
RangeTransition
Recognizer<ATNInterpreter extends ATNSimulator>
RuleContext
A rule context is a record of a single rule invocation.
RuleNode
RuleStartState
RuleStopState
The last node in the ATN for a rule, unless that rule is the start symbol. In that case, there is one transition to EOF. Later, we might encode references to all calls to this rule to compute FOLLOW sets for error handling.
RuleTagToken
A Token object representing an entire subtree matched by a parser rule; e.g., {@code
RuleTransition
RuntimeMetaData
This class provides access to the current version of the ANTLR 4 runtime library as compile-time and runtime constants, along with methods for checking for matching version numbers and notifying listeners in the case where a version mismatch is detected.
SemanticContext
A tree structure used to record the semantic context in which an ATN configuration is valid. It's either a single predicate, a conjunction {@code p1&&p2}, or a sum of products {@code p1||p2}.
SetTransition
SimState
When we hit an accept state in either the DFA or the ATN, we have to notify the character stream to start buffering characters via {@link IntStream#mark} and record the current state. The current sim state includes the current index into the input, the current line, and current character position in that line. Note that the Lexer is tracking the starting line and characterization of the token. These variables track the "state" of the simulator when it hits an accept state.
SingletonPredictionContext
StarBlockStartState
The block that begins a closure loop.
StarLoopbackState
StarLoopEntryState
SyntaxTree
TagChunk
Represents a placeholder tag in a tree pattern. A tag can have any of the following forms.
TerminalNode
TerminalNodeImpl
TextChunk
Represents a span of raw text (concrete syntax) between tags in a tree pattern string.
Token
A token has properties: text, type, line, character position in the line (so we can ignore tabs), token channel, index, and source from which we obtained this token.
TokenFactory<Symbol extends Token>
The default mechanism for creating tokens. It's used by default in Lexer and the error handling strategy (to create missing tokens). Notifying the parser of a new factory means that it notifies its token source and error strategy.
TokenSource
A source of tokens must provide a sequence of tokens via {@link #nextToken()} and also must reveal it's source of characters; CommonToken's text is computed from a CharStream; it only store indices into the char stream.
TokensStartState
The Tokens rule start state linking to each lexer rule start state */
TokenStream
An IntStream whose symbols are Token instances.
TokenTagToken
A Token object representing a token of a particular type; e.g., {@code
TraceListener
Transition
An ATN transition between any two ATN states. Subclasses define atom, set, epsilon, action, predicate, rule transitions.
Tree
The basic notion of a tree has a parent, a payload, and a list of children. It is the most abstract interface for all the trees used by ANTLR.
Trees
A set of utility routines useful for all kinds of ANTLR trees. */
TrimToSizeListener
Vocabulary
This interface provides information about the vocabulary used by a recognizer.
VocabularyImpl
This class provides a default implementation of the Vocabulary interface.
WildcardTransition
WritableToken

Enums

PredictionMode
This enumeration defines the prediction modes available in ANTLR 4 along with utility methods for analyzing configuration sets for conflicts and/or ambiguities.
StateType
TransitionType

Properties

defaultConfigLookup HashSet<ATNConfig> Function()
final
INITIAL_NUM_TRANSITIONS int
getter/setter pair

Functions

checkParams(dynamic params, dynamic isCfg) Map<String, dynamic>
TEST_platformStdoutWrite(Object? object) → void
Hack to workaround not being able to access stdout in tests.

Exceptions / Errors

CannotInvokeStartRule
FailedPredicateException
A semantic predicate failed during validation. Validation of predicates occurs when normally parsing the alternative just like matching a token. Disambiguating predicate evaluation occurs when we test a predicate during prediction.
InputMismatchException
This signifies any kind of mismatched input exceptions such as when the current input does not match the expected token.
LexerNoViableAltException
NoViableAltException
Indicates that the parser could not decide which of two or more paths to take based upon the remaining input. It tracks the starting token of the offending input and also knows where the parser was in the various paths when the error. Reported by reportNoViableAlternative()
ParseCancellationException
This exception is thrown to cancel a parsing operation. This exception does not extend RecognitionException, allowing it to bypass the standard error recovery mechanisms. BailErrorStrategy throws this exception in response to a parse error.
RecognitionException<StreamType extends IntStream>
The root of the ANTLR exception hierarchy. In general, ANTLR tracks just 3 kinds of errors: prediction errors, failed predicate errors, and mismatched input errors. In each case, the parser knows where it is in the input, where it is in the ATN, the rule invocation stack, and what kind of problem occurred.
StartRuleDoesNotConsumeFullPattern