Package org.antlr.analysis
Class NFAConfiguration
java.lang.Object
org.antlr.analysis.NFAConfiguration
An NFA state, predicted alt, and syntactic/semantic context.
The syntactic context is a pointer into the rule invocation
chain used to arrive at the state. The semantic context is
the unordered set semantic predicates encountered before reaching
an NFA state.
-
Field Summary
FieldsModifier and TypeFieldDescriptionint
What alt is predicted by this configurationWhat is the stack of rule invocations that got us to state?protected int
Lots of NFA states have only epsilon edges (1 or 2).protected boolean
Indicate that this configuration has been resolved and no further DFA processing should occur with it.protected boolean
This bit is used to indicate a semantic predicate will be used to resolve the conflict.The set of semantic predicates associated with this NFA configuration.protected boolean
Indicates that the NFA state associated with this configuration has exactly one transition and it's an atom (not epsilon etc...).int
The NFA state associated with this configuration -
Constructor Summary
ConstructorsConstructorDescriptionNFAConfiguration
(int state, int alt, NFAContext context, SemanticContext semanticContext) -
Method Summary
-
Field Details
-
state
public int stateThe NFA state associated with this configuration -
alt
public int altWhat alt is predicted by this configuration -
context
What is the stack of rule invocations that got us to state? -
semanticContext
The set of semantic predicates associated with this NFA configuration. The predicates were found on the way to the associated NFA state in this syntactic context. Set: track nodes in grammar containing the predicate for error messages and such (nice to know where the predicate came from in case of duplicates etc...). By using a set, the equals() method will correctly show {pred1,pred2} as equals() to {pred2,pred1}. -
resolved
protected boolean resolvedIndicate that this configuration has been resolved and no further DFA processing should occur with it. Essentially, this is used as an "ignore" bit so that upon a set of nondeterministic configurations such as (s|2) and (s|3), I can set (s|3) to resolved=true (and any other configuration associated with alt 3). -
resolveWithPredicate
protected boolean resolveWithPredicateThis bit is used to indicate a semantic predicate will be used to resolve the conflict. Method DFA.findNewDFAStatesAndAddDFATransitions will add edges for the predicates after it performs the reach operation. The nondeterminism resolver sets this when it finds a set of nondeterministic configurations (as it does for "resolved" field) that have enough predicates to resolve the conflit. -
numberEpsilonTransitionsEmanatingFromState
protected int numberEpsilonTransitionsEmanatingFromStateLots of NFA states have only epsilon edges (1 or 2). We can safely consider only n>0 during closure. -
singleAtomTransitionEmanating
protected boolean singleAtomTransitionEmanatingIndicates that the NFA state associated with this configuration has exactly one transition and it's an atom (not epsilon etc...).
-
-
Constructor Details
-
NFAConfiguration
-
-
Method Details
-
equals
An NFA configuration is equal to another if both have the same state, the predict the same alternative, and syntactic/semantic contexts are the same. I don't think the state|alt|ctx could be the same and have two different semantic contexts, but might as well define equals to be everything. -
hashCode
public int hashCode() -
toString
-
toString
-