Class ATNState

java.lang.Object
org.antlr.v4.runtime.atn.ATNState
Direct Known Subclasses:
BasicState, BlockEndState, DecisionState, LoopEndState, RuleStartState, RuleStopState, StarLoopbackState

public abstract class ATNState extends Object
The following images show the relation of states and transitions for various grammar constructs.
  • Solid edges marked with an ε indicate a required EpsilonTransition.
  • Dashed edges indicate locations where any transition derived from Transition might appear.
  • Dashed nodes are place holders for either a sequence of linked BasicState states or the inclusion of a block representing a nested construct in one of the forms below.
  • Nodes showing multiple outgoing alternatives with a ... support any number of alternatives (one or more). Nodes without the ... only support the exact number of alternatives shown in the diagram.

Basic Blocks

Rule

Block of 1 or more alternatives

Greedy Loops

Greedy Closure: (...)*

Greedy Positive Closure: (...)+

Greedy Optional: (...)?

Non-Greedy Loops

Non-Greedy Closure: (...)*?

Non-Greedy Positive Closure: (...)+?

Non-Greedy Optional: (...)??

  • Field Details

  • Constructor Details

    • ATNState

      public ATNState()
  • Method Details

    • frozenOptimizedTransitions

      final Transition[] frozenOptimizedTransitions()
      Frozen optimized-transition array after freezeOptimizedTransitions(), else null. Package-private so reach/closure can hoist the snapshot once per state.
    • getStateNumber

      public final int getStateNumber()
      Gets the state number.
      Returns:
      the state number
    • getNonStopStateNumber

      public int getNonStopStateNumber()
      For all states except RuleStopState, this returns the state number. Returns -1 for stop states.
      Returns:
      -1 for RuleStopState, otherwise the state number
    • hashCode

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • isNonGreedyExitState

      public boolean isNonGreedyExitState()
    • toString

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

      public Transition[] getTransitions()
    • getNumberOfTransitions

      public int getNumberOfTransitions()
    • addTransition

      public void addTransition(Transition e)
    • addTransition

      public void addTransition(int index, Transition e)
    • transition

      public Transition transition(int i)
    • setTransition

      public void setTransition(int i, Transition e)
    • removeTransition

      public Transition removeTransition(int index)
    • getStateType

      public abstract int getStateType()
    • onlyHasEpsilonTransitions

      public final boolean onlyHasEpsilonTransitions()
    • setRuleIndex

      public void setRuleIndex(int ruleIndex)
    • isOptimized

      public boolean isOptimized()
    • getNumberOfOptimizedTransitions

      public int getNumberOfOptimizedTransitions()
    • getOptimizedTransition

      public Transition getOptimizedTransition(int i)
    • addOptimizedTransition

      public void addOptimizedTransition(Transition e)
    • setOptimizedTransition

      public void setOptimizedTransition(int i, Transition e)
    • removeOptimizedTransition

      public void removeOptimizedTransition(int i)
    • freezeOptimizedTransitions

      public final void freezeOptimizedTransitions()
      Snapshot optimizedTransitions into a fixed array for hot-path reads. Safe to call multiple times. When the list is empty, the snapshot is the shared Transition.EMPTY_ARRAY.

      Invoked once per state after ATN deserialization / optimization so runtime prediction never pays ArrayList dispatch on transition walks. Subsequent mutations of optimized transitions (or of transitions while it is still aliased as the optimized list) invalidate the snapshot automatically.