getExistingTargetState method
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.
@param previousD The current DFA state
@param t The next input symbol
@return The existing target DFA state for the given input symbol
t
, or null if the target state for this edge is not
already cached
Implementation
@override
DFAState? getExistingTargetState(DFAState previousD, int t) {
// this method is called after each time the input position advances
// during SLL prediction
_sllStopIndex = input.index;
final existingTargetState = super.getExistingTargetState(previousD, t);
if (existingTargetState != null) {
// count only if we transition over a DFA state
decisions[currentDecision].SLL_DFATransitions += 1;
if (existingTargetState == ATNSimulator.ERROR) {
decisions[currentDecision].errors.add(
ErrorInfo(
currentDecision,
previousD.configs,
input,
startIndex,
_sllStopIndex,
false,
),
);
}
}
currentState = existingTargetState;
return existingTargetState;
}