Package org.antlr.analysis
Class NFAConfiguration
- java.lang.Object
-
- org.antlr.analysis.NFAConfiguration
-
public class NFAConfiguration extends java.lang.Object
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
Fields Modifier and Type Field Description int
alt
What alt is predicted by this configurationNFAContext
context
What is the stack of rule invocations that got us to state?protected int
numberEpsilonTransitionsEmanatingFromState
Lots of NFA states have only epsilon edges (1 or 2).protected boolean
resolved
Indicate that this configuration has been resolved and no further DFA processing should occur with it.protected boolean
resolveWithPredicate
This bit is used to indicate a semantic predicate will be used to resolve the conflict.SemanticContext
semanticContext
The set of semantic predicates associated with this NFA configuration.protected boolean
singleAtomTransitionEmanating
Indicates that the NFA state associated with this configuration has exactly one transition and it's an atom (not epsilon etc...).int
state
The NFA state associated with this configuration
-
Constructor Summary
Constructors Constructor Description NFAConfiguration(int state, int alt, NFAContext context, SemanticContext semanticContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
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.int
hashCode()
java.lang.String
toString()
java.lang.String
toString(boolean showAlt)
-
-
-
Field Detail
-
state
public int state
The NFA state associated with this configuration
-
alt
public int alt
What alt is predicted by this configuration
-
context
public NFAContext context
What is the stack of rule invocations that got us to state?
-
semanticContext
public SemanticContext 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<AST>: 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 resolved
Indicate 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 resolveWithPredicate
This 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 numberEpsilonTransitionsEmanatingFromState
Lots of NFA states have only epsilon edges (1 or 2). We can safely consider only n>0 during closure.
-
singleAtomTransitionEmanating
protected boolean singleAtomTransitionEmanating
Indicates that the NFA state associated with this configuration has exactly one transition and it's an atom (not epsilon etc...).
-
-
Constructor Detail
-
NFAConfiguration
public NFAConfiguration(int state, int alt, NFAContext context, SemanticContext semanticContext)
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
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.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toString
public java.lang.String toString(boolean showAlt)
-
-