Class DFAState
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMap a predicate to a predicted alternative. -
Field Summary
FieldsModifier and TypeFieldDescriptionDFAState[]edges[symbol]points to target of symbol.booleanDuring SLL parsing, this is a list of predicates associated with the ATN configurations of the DFA state.intif accept state, what ttype do we match or alt do we predict? This is set toATN.INVALID_ALT_NUMBERwhenpredicates!=nullorrequiresFullContext.booleanIndicates that this state was created during SLL prediction that discovered a conflict between the configurations in the state.int -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
stateNumber
public int stateNumber -
configs
-
edges
-
isAcceptState
public boolean isAcceptState -
prediction
public int predictionif accept state, what ttype do we match or alt do we predict? This is set toATN.INVALID_ALT_NUMBERwhenpredicates!=nullorrequiresFullContext. -
lexerActionExecutor
-
requiresFullContext
public boolean requiresFullContextIndicates that this state was created during SLL prediction that discovered a conflict between the configurations in the state. FutureParserATNSimulator.execATN(DFA, DFAState, TokenStream, int, ParserRuleContext)invocations immediately jumped doing full context prediction if this field is true. -
predicates
During SLL parsing, this is a list of predicates associated with the ATN configurations of the DFA state. When we have predicates,requiresFullContextisfalsesince full context prediction evaluates predicates on-the-fly. If this is not null, thenpredictionisATN.INVALID_ALT_NUMBER.We only use these for non-
requiresFullContextbut conflicting states. That means we know from the context (it's $ or we don't dip into outer context) that it's an ambiguity not a conflict.This list is computed by
ParserATNSimulator.predicateDFAState(DFAState, DecisionState).
-
-
Constructor Details
-
DFAState
public DFAState() -
DFAState
public DFAState(int stateNumber) -
DFAState
-
-
Method Details
-
getAltSet
-
hashCode
-
equals
TwoDFAStateinstances are equal if their ATN configuration sets are the same. This method is used to see if a state already exists.Because the number of alternatives and number of ATN configurations are finite, there is a finite number of DFA states that can be processed. This is necessary to show that the algorithm terminates.
Cannot test the DFA state numbers here because in
ParserATNSimulator.addDFAState(DFA, DFAState)we need to know if any other state exists that has this exact set of ATN configurations. ThestateNumberis irrelevant. -
toString
-