Class DFA


  • public class DFA
    extends Object
    • Field Detail

      • states

        public final Map<DFAState,​DFAState> states
        A set of all DFA states. Use Map so we can get old state back (Set only allows you to see if it's there).
      • decision

        public final int decision
      • atnStartState

        public final DecisionState atnStartState
        From which ATN state did we create this DFA?
    • Method Detail

      • isPrecedenceDfa

        public final boolean isPrecedenceDfa()
        Gets whether this DFA is a precedence DFA. Precedence DFAs use a special start state s0 which is not stored in states. The DFAState.edges array for this start state contains outgoing edges supplying individual start states corresponding to specific precedence values.
        Returns:
        true if this is a precedence DFA; otherwise, false.
        See Also:
        Parser.getPrecedence()
      • getPrecedenceStartState

        public final DFAState getPrecedenceStartState​(int precedence)
        Get the start state for a specific precedence value.
        Parameters:
        precedence - The current precedence.
        Returns:
        The start state corresponding to the specified precedence, or null if no start state exists for the specified precedence.
        Throws:
        IllegalStateException - if this is not a precedence DFA.
        See Also:
        isPrecedenceDfa()
      • setPrecedenceStartState

        public final void setPrecedenceStartState​(int precedence,
                                                  DFAState startState)
        Set the start state for a specific precedence value.
        Parameters:
        precedence - The current precedence.
        startState - The start state corresponding to the specified precedence.
        Throws:
        IllegalStateException - if this is not a precedence DFA.
        See Also:
        isPrecedenceDfa()
      • setPrecedenceDfa

        @Deprecated
        public final void setPrecedenceDfa​(boolean precedenceDfa)
        Deprecated.
        This method no longer performs any action.
        Sets whether this is a precedence DFA.
        Parameters:
        precedenceDfa - true if this is a precedence DFA; otherwise, false
        Throws:
        UnsupportedOperationException - if precedenceDfa does not match the value of isPrecedenceDfa() for the current DFA.
      • getStates

        public List<DFAState> getStates()
        Return a list of all states in this DFA, ordered by state number.
      • toLexerString

        public String toLexerString()