public class DFAState
extends java.lang.Object
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
DFAState.PredPrediction
Map a predicate to a predicted alternative.
|
| Modifier and Type | Field and Description |
|---|---|
ATNConfigSet |
configs |
DFAState[] |
edges
edges[symbol] points to target of symbol. |
boolean |
isAcceptState |
LexerActionExecutor |
lexerActionExecutor |
DFAState.PredPrediction[] |
predicates
During SLL parsing, this is a list of predicates associated with the
ATN configurations of the DFA state.
|
int |
prediction
if accept state, what ttype do we match or alt do we predict?
This is set to
ATN.INVALID_ALT_NUMBER when predicates!=null or
requiresFullContext. |
boolean |
requiresFullContext
Indicates that this state was created during SLL prediction that
discovered a conflict between the configurations in the state.
|
int |
stateNumber |
| Constructor and Description |
|---|
DFAState() |
DFAState(ATNConfigSet configs) |
DFAState(int stateNumber) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o)
Two
DFAState instances are equal if their ATN configuration sets
are the same. |
java.util.Set<java.lang.Integer> |
getAltSet()
Get the set of all alts mentioned by all ATN configurations in this
DFA state.
|
int |
hashCode() |
java.lang.String |
toString() |
public int stateNumber
public ATNConfigSet configs
public DFAState[] edges
public boolean isAcceptState
public int prediction
ATN.INVALID_ALT_NUMBER when predicates!=null or
requiresFullContext.public LexerActionExecutor lexerActionExecutor
public boolean requiresFullContext
ParserATNSimulator.execATN(org.antlr.v4.runtime.dfa.DFA, org.antlr.v4.runtime.dfa.DFAState, org.antlr.v4.runtime.TokenStream, int, org.antlr.v4.runtime.ParserRuleContext) invocations immediately jumped doing
full context prediction if this field is true.public DFAState.PredPrediction[] predicates
requiresFullContext is false since full context prediction evaluates predicates
on-the-fly. If this is not null, then prediction is
ATN.INVALID_ALT_NUMBER.
We only use these for non-requiresFullContext but 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(org.antlr.v4.runtime.dfa.DFAState, org.antlr.v4.runtime.atn.DecisionState).
public DFAState()
public DFAState(int stateNumber)
public DFAState(ATNConfigSet configs)
public java.util.Set<java.lang.Integer> getAltSet()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
DFAState instances 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(org.antlr.v4.runtime.dfa.DFA, org.antlr.v4.runtime.dfa.DFAState) we need to know if any other state
exists that has this exact set of ATN configurations. The
stateNumber is irrelevant.
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object