Class NFAConfiguration

java.lang.Object
org.antlr.analysis.NFAConfiguration

public class NFAConfiguration extends 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
    What alt is predicted by this configuration
    What 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

    Constructors
    Constructor
    Description
    NFAConfiguration(int state, int alt, NFAContext context, SemanticContext semanticContext)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    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
     
     
    toString(boolean showAlt)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • 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 Details

  • Method Details

    • equals

      public boolean equals(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 class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(boolean showAlt)