LexerATNSimulator class
"dup" of ParserInterpreter */
- Inheritance
-
- Object
- ATNSimulator
- LexerATNSimulator
Constructors
-
LexerATNSimulator(ATN atn, List<
DFA> decisionToDFA, required Lexer recog})
Properties
- atn → ATN
-
finalinherited
- charPositionInLine ↔ int
-
The index of the character relative to the beginning of the line 0..n-1 */
getter/setter pair
-
decisionToDFA
↔ List<
DFA> -
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- line ↔ int
-
line number 1..n within the input */
getter/setter pair
- mode ↔ int
-
getter/setter pair
- prevAccept → SimState
-
Used during DFA/ATN exec to record the most recent accept configuration info */
final
- recog → Lexer
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
The context cache maps all PredictionContext objects that are equals()
to a single cached copy. This cache is shared across all contexts
in all ATNConfigs in all DFA states. We rebuild each ATNConfigSet
to use only cached nodes/graphs in addDFAState(). We don't want to
fill this during closure() since there are lots of contexts that
pop up but are not used ever again. It also greatly slows down closure().
finalinherited
- startIndex ↔ int
-
The current token's starting index into the character stream.
Shared across DFA to ATN simulation in case the ATN fails and the
DFA did not have a previous accept state. In this case, we use the
ATN-generated exception object.
getter/setter pair
Methods
-
accept(
CharStream input, LexerActionExecutor? lexerActionExecutor, int startIndex, int index, int line, int charPos) → void -
addDFAEdge(
DFAState p, int t, DFAState q) → void -
addDFAEdgeByConfig(
DFAState from, int t, ATNConfigSet q) → DFAState -
addDFAState(
ATNConfigSet configs) → DFAState - Add a new DFA state if there isn't one with this set of configurations already. This method also detects the first configuration containing an ATN rule stop state. Later, when traversing the DFA, we will know which rule to accept.
-
captureSimState(
SimState settings, CharStream input, DFAState dfaState) → void -
clearDFA(
) → void -
Clear the DFA cache used by the current instance. Since the DFA cache may
be shared by multiple ATN simulators, this method may affect the
performance (but not accuracy) of other parsers which are being used
concurrently.
override
-
closure(
CharStream input, LexerATNConfig config, ATNConfigSet configs, bool currentAltReachedAcceptState, bool speculative, bool treatEofAsEpsilon) → bool -
Since the alternatives within any lexer decision are ordered by
preference, this method stops pursuing the closure as soon as an accept
state is reached. After the first accept state is reached by depth-first
search from
config
, all other (potentially reachable) states for this rule would have a lower priority. -
computeStartState(
CharStream input, ATNState p) → ATNConfigSet -
computeTargetState(
CharStream input, DFAState s, int t) → DFAState - Compute a target state for an edge in the DFA, and attempt to add the computed state and corresponding edge to the DFA.
-
consume(
CharStream input) → void -
copyState(
LexerATNSimulator simulator) → void -
evaluatePredicate(
CharStream input, int ruleIndex, int predIndex, bool speculative) → bool - Evaluate a predicate specified in the lexer.
-
execATN(
CharStream input, DFAState ds0) → int -
failOrAccept(
SimState prevAccept, CharStream input, ATNConfigSet reach, int t) → int -
getCachedContext(
PredictionContext context) → PredictionContext -
inherited
-
getDFA(
int mode) → DFA -
getEpsilonTarget(
CharStream input, LexerATNConfig config, Transition t, ATNConfigSet configs, bool speculative, bool treatEofAsEpsilon) → LexerATNConfig? -
getExistingTargetState(
DFAState s, int t) → DFAState? - Get an existing target state for an edge in the DFA. If the target state for the edge has not yet been computed or is otherwise not available, this method returns null.
-
getReachableConfigSet(
CharStream input, ATNConfigSet configs, ATNConfigSet reach, int t) → void -
Given a starting configuration set, figure out all ATN configurations
we can reach upon input
t
. Parameterreach
is a return parameter. -
getReachableTarget(
Transition trans, int t) → ATNState? -
getText(
CharStream input) → String - Get the text matched so far for the current token.
-
getTokenName(
int t) → String -
match(
CharStream input, int mode) → int -
matchATN(
CharStream input) → int -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void -
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- debug → const bool
- dfa_debug → const bool
- MAX_DFA_EDGE → const int
- MIN_DFA_EDGE → const int