DFAState class

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.

I use a set of ATNConfig objects not simple states. An ATNConfig is both a state (ala normal conversion) and a RuleContext describing the chain of rules (if any) followed to arrive at that state.

A DFA state may have multiple references to a particular state, but with different ATN contexts (with same or different alts) meaning that state was reached via a different set of rule invocations.

Constructors

DFAState({int stateNumber = -1, required ATNConfigSet configs})

Properties

altSet Set<int>?
Get the set of all alts mentioned by all ATN configurations in this DFA state.
no setter
configs ATNConfigSet
getter/setter pair
edges List<DFAState?>?
{@code edgessymbol} points to target of symbol. Shift up by 1 so (-1) {@link Token#EOF} maps to {@code edges0}.
getter/setter pair
hashCode int
The hash code for this object.
no setteroverride
isAcceptState bool
getter/setter pair
lexerActionExecutor LexerActionExecutor?
getter/setter pair
predicates List<PredPrediction>?
During SLL parsing, this is a list of predicates associated with the ATN configurations of the DFA state. When we have predicates, {@link #requiresFullContext} is false since full context prediction evaluates predicates on-the-fly. If this is not null, then {@link #prediction} is {@link ATN#INVALID_ALT_NUMBER}.
getter/setter pair
prediction int
if accept state, what ttype do we match or alt do we predict? This is set to {@link ATN#INVALID_ALT_NUMBER} when {@link #predicates}{@code !=null} or {@link #requiresFullContext}.
getter/setter pair
requiresFullContext bool
Indicates that this state was created during SLL prediction that discovered a conflict between the configurations in the state. Future {@link ParserATNSimulator#execATN} invocations immediately jumped doing full context prediction if this field is true.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stateNumber int
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
Two DFAState instances are equal if their ATN configuration sets are the same. This method is used to see if a state already exists.
override