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).
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.
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.
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.
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).
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.
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.
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.
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.
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.
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:
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 }.
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}.
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+}.
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.
This implementation of ErrorListener dispatches all calls to a
collection of delegate listeners. This reduces the effort required to support multiple
listeners.
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.
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.
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}.
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.
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.
This enumeration defines the prediction modes available in ANTLR 4 along with
utility methods for analyzing configuration sets for conflicts and/or
ambiguities.
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.
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()
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.
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.