Top Description Fields Constructors Methods
org.antlr.analysis

public Class NFAConfiguration

extends Object
Class Inheritance
Imports
org.antlr.misc.Utils

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

Modifier and TypeField and Description
public int
alt

What alt is predicted by this configuration

public NFAContext
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.

public 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...).

public int
state

The NFA state associated with this configuration

Constructor Summary

AccessConstructor and Description
public
NFAConfiguration(int state, int alt, NFAContext context, SemanticContext semanticContext)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.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.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public String
toString(boolean showAlt)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

altback to summary
public int alt

What alt is predicted by this configuration

contextback to summary
public NFAContext context

What is the stack of rule invocations that got us to state?

numberEpsilonTransitionsEmanatingFromStateback to summary
protected int numberEpsilonTransitionsEmanatingFromState

Lots of NFA states have only epsilon edges (1 or 2). We can safely consider only n>0 during closure.

resolvedback to summary
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).

resolveWithPredicateback to summary
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.

semanticContextback to summary
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}.

singleAtomTransitionEmanatingback to summary
protected boolean singleAtomTransitionEmanating

Indicates that the NFA state associated with this configuration has exactly one transition and it's an atom (not epsilon etc...).

stateback to summary
public int state

The NFA state associated with this configuration

Constructor Detail

NFAConfigurationback to summary
public NFAConfiguration(int state, int alt, NFAContext context, SemanticContext semanticContext)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.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.

Parameters
o:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
toStringback to summary
public String toString(boolean showAlt)