public class DFAState extends State
Modifier and Type | Field and Description |
---|---|
protected boolean |
abortedDueToMultipleRecursiveAlts
If we detect recursion on more than one alt, decision is non-LL(*),
but try to isolate it to only those states whose closure operations
detect recursion.
|
boolean |
abortedDueToRecursionOverflow
If a closure operation finds that we tried to invoke the same
rule too many times (stack would grow beyond a threshold), it
marks the state has aborted and notifies the DecisionProbe.
|
protected int |
acceptStateReachable
The NFA→DFA algorithm may terminate leaving some states
without a path to an accept state, implying that upon certain
input, the decision is not deterministic--no decision about
predicting a unique alternative can be made.
|
boolean |
atLeastOneConfigurationHasAPredicate |
protected int |
cachedHashCode
Build up the hash code for this state as NFA configurations
are added as it's monotonically increasing list of configurations.
|
protected int |
cachedUniquelyPredicatedAlt |
protected Set<NFAConfiguration> |
closureBusy
Used to prevent the closure operation from looping to itself and
hence looping forever.
|
List<NFAConfiguration> |
configurationsWithLabeledEdges |
DFA |
dfa
We are part of what DFA? Use this ref to get access to the
context trees for an alt.
|
static int |
INITIAL_NUM_TRANSITIONS |
protected int |
k
When doing an acyclic DFA, this is the number of lookahead symbols
consumed to reach this state.
|
int |
minAltInConfigurations |
OrderedHashSet<NFAConfiguration> |
nfaConfigurations
The set of NFA configurations (state,alt,context) for this DFA state
|
static int |
PREDICTED_ALT_UNSET |
protected OrderedHashSet<Label> |
reachableLabels
As this state is constructed (i.e., as NFA states are added), we
can easily check for non-epsilon transitions because the only
transition that could be a valid label is transition(0).
|
protected boolean |
resolvedWithPredicates
Rather than recheck every NFA configuration in a DFA state (after
resolving) in findNewDFAStatesAndAddDFATransitions just check
this boolean.
|
protected List<Transition> |
transitions
Track the transitions emanating from this DFA state.
|
acceptState, INVALID_STATE_NUMBER, stateNumber
Modifier and Type | Method and Description |
---|---|
NFAConfiguration |
addNFAConfiguration(NFAState state,
int alt,
NFAContext context,
SemanticContext semanticContext) |
void |
addNFAConfiguration(NFAState state,
NFAConfiguration c)
Add an NFA configuration to this DFA node.
|
protected void |
addReachableLabel(Label label)
Add label uniquely and disjointly; intersection with
another set or int/char forces breaking up the set(s).
|
int |
addTransition(DFAState target,
Label label)
Add a transition from this state to target with label.
|
void |
addTransition(Transition t) |
boolean |
equals(Object o)
Two DFAStates are equal if their NFA configuration sets are the
same.
|
int |
getAcceptStateReachable()
Is an accept state reachable from this state?
|
Set<Integer> |
getAltSet()
Get the set of all alts mentioned by all NFA configurations in this
DFA state.
|
protected Set<Integer> |
getConflictingAlts()
Walk each NFA configuration in this DFA state looking for a conflict
where (s|i|ctx) and (s|j|ctx) exist, indicating that state s with
context conflicting ctx predicts alts i and j.
|
Set<Integer> |
getDisabledAlternatives()
When more than one alternative can match the same input, the first
alternative is chosen to resolve the conflict.
|
SemanticContext |
getGatedPredicatesInNFAConfigurations()
For gated productions, we need an OR'd list of all predicates for the
target of an edge so we can gate the edge based upon the predicates
associated with taking that path (if any).
|
Set<? extends SemanticContext> |
getGatedSyntacticPredicatesInNFAConfigurations() |
int |
getLookaheadDepth() |
protected Set<Integer> |
getNonDeterministicAlts() |
int |
getNumberOfTransitions() |
OrderedHashSet<Label> |
getReachableLabels() |
Transition |
getTransition(int trans) |
int |
getUniqueAlt()
Return the uniquely mentioned alt from the NFA configurations;
Ignore the resolved bit etc...
|
int |
getUniquelyPredictedAlt()
Walk each configuration and if they are all the same alt, return
that alt else return NFA.INVALID_ALT_NUMBER.
|
int |
hashCode()
A decent hash for a DFA state is the sum of the NFA state/alt pairs.
|
boolean |
isResolvedWithPredicates() |
void |
removeTransition(int trans) |
void |
reset() |
void |
setAcceptStateReachable(int acceptStateReachable) |
void |
setLookaheadDepth(int k) |
void |
setNFAConfigurations(OrderedHashSet<NFAConfiguration> configs) |
String |
toString()
Print all NFA states plus what alts they predict
|
Transition |
transition(int i) |
isAcceptState, setAcceptState
public static final int INITIAL_NUM_TRANSITIONS
public static final int PREDICTED_ALT_UNSET
public DFA dfa
protected List<Transition> transitions
protected int k
protected int acceptStateReachable
protected boolean resolvedWithPredicates
public boolean abortedDueToRecursionOverflow
protected boolean abortedDueToMultipleRecursiveAlts
protected int cachedHashCode
protected int cachedUniquelyPredicatedAlt
public int minAltInConfigurations
public boolean atLeastOneConfigurationHasAPredicate
public OrderedHashSet<NFAConfiguration> nfaConfigurations
public List<NFAConfiguration> configurationsWithLabeledEdges
protected Set<NFAConfiguration> closureBusy
protected OrderedHashSet<Label> reachableLabels
public DFAState(DFA dfa)
public void reset()
public Transition transition(int i)
transition
in class State
public int getNumberOfTransitions()
getNumberOfTransitions
in class State
public void addTransition(Transition t)
addTransition
in class State
public int addTransition(DFAState target, Label label)
public Transition getTransition(int trans)
public void removeTransition(int trans)
public void addNFAConfiguration(NFAState state, NFAConfiguration c)
public NFAConfiguration addNFAConfiguration(NFAState state, int alt, NFAContext context, SemanticContext semanticContext)
protected void addReachableLabel(Label label)
public OrderedHashSet<Label> getReachableLabels()
public void setNFAConfigurations(OrderedHashSet<NFAConfiguration> configs)
public int hashCode()
public boolean equals(Object o)
public int getUniquelyPredictedAlt()
public int getUniqueAlt()
public Set<Integer> getDisabledAlternatives()
protected Set<Integer> getConflictingAlts()
public Set<Integer> getAltSet()
public Set<? extends SemanticContext> getGatedSyntacticPredicatesInNFAConfigurations()
public SemanticContext getGatedPredicatesInNFAConfigurations()
public int getAcceptStateReachable()
public void setAcceptStateReachable(int acceptStateReachable)
public boolean isResolvedWithPredicates()
public String toString()
public int getLookaheadDepth()
public void setLookaheadDepth(int k)
Copyright © 1992–2015 ANTLR. All rights reserved.