Top Description Fields Constructors Methods
org.antlr.v4.runtime.atn

public abstract Class ATNState

extends Object
Class Inheritance
Known Direct Subclasses
org.antlr.v4.runtime.atn.BasicState, org.antlr.v4.runtime.atn.DecisionState, org.antlr.v4.runtime.atn.LoopEndState, org.antlr.v4.runtime.atn.RuleStartState, org.antlr.v4.runtime.atn.RuleStopState, org.antlr.v4.runtime.atn.StarLoopbackState, org.antlr.v4.runtime.atn.BlockEndState
Imports
org.antlr.v4.runtime.misc.IntervalSet, java.util.ArrayList, .Arrays, .Collections, .List, .Locale

The following images show the relation of states and ATNState#transitions for various grammar constructs.

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 Summary

Modifier and TypeField and Description
public ATN
atn

Which ATN are we in?

public static final int
public static final int
public static final int
public boolean
public static final int
public static final int
public static final int
public static final int
public IntervalSet
nextTokenWithinRule

Used to cache lookahead during parsing, not used during construction

protected List<Transition>
public static final int
public static final int
public static final int
public static final int
public int
public static final List<String>
public static final int
public static final int
public static final int
public int
public static final int
protected final List<Transition>
transitions

Track the transitions emanating from this ATN state.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
addTransition(int index, Transition e)

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int

Returns:

-1 for RuleStopState, otherwise the state number
getNonStopStateNumber
()

For all states except RuleStopState, this returns the state number.

public int
public int
public Transition
public final int

Returns:

the state number
getStateNumber
()

Gets the state number.

public abstract int
public Transition[]
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
public boolean
public final boolean
public void
public Transition
removeTransition(int index)

public void
public void
setRuleIndex(int ruleIndex)

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Transition
transition(int i)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

atnback to summary
public ATN atn

Which ATN are we in?

BASICback to summary
public static final int BASIC
BLOCK_ENDback to summary
public static final int BLOCK_END
BLOCK_STARTback to summary
public static final int BLOCK_START
epsilonOnlyTransitionsback to summary
public boolean epsilonOnlyTransitions
INITIAL_NUM_TRANSITIONSback to summary
public static final int INITIAL_NUM_TRANSITIONS
INVALID_STATE_NUMBERback to summary
public static final int INVALID_STATE_NUMBER
INVALID_TYPEback to summary
public static final int INVALID_TYPE
LOOP_ENDback to summary
public static final int LOOP_END
nextTokenWithinRuleback to summary
public IntervalSet nextTokenWithinRule

Used to cache lookahead during parsing, not used during construction

optimizedTransitionsback to summary
protected List<Transition> optimizedTransitions
PLUS_BLOCK_STARTback to summary
public static final int PLUS_BLOCK_START
PLUS_LOOP_BACKback to summary
public static final int PLUS_LOOP_BACK
RULE_STARTback to summary
public static final int RULE_START
RULE_STOPback to summary
public static final int RULE_STOP
ruleIndexback to summary
public int ruleIndex
serializationNamesback to summary
public static final List<String> serializationNames
STAR_BLOCK_STARTback to summary
public static final int STAR_BLOCK_START
STAR_LOOP_BACKback to summary
public static final int STAR_LOOP_BACK
STAR_LOOP_ENTRYback to summary
public static final int STAR_LOOP_ENTRY
stateNumberback to summary
public int stateNumber
TOKEN_STARTback to summary
public static final int TOKEN_START
transitionsback to summary
protected final List<Transition> transitions

Track the transitions emanating from this ATN state.

Constructor Detail

ATNStateback to summary
public ATNState()

Method Detail

addOptimizedTransitionback to summary
public void addOptimizedTransition(Transition e)
addTransitionback to summary
public void addTransition(Transition e)
addTransitionback to summary
public void addTransition(int index, Transition e)
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

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

Annotations
@Override
getNonStopStateNumberback to summary
public int getNonStopStateNumber()

For all states except RuleStopState, this returns the state number. Returns -1 for stop states.

Returns:int

-1 for RuleStopState, otherwise the state number

getNumberOfOptimizedTransitionsback to summary
public int getNumberOfOptimizedTransitions()
getNumberOfTransitionsback to summary
public int getNumberOfTransitions()
getOptimizedTransitionback to summary
public Transition getOptimizedTransition(int i)
getStateNumberback to summary
public final int getStateNumber()

Gets the state number.

Returns:int

the state number

getStateTypeback to summary
public abstract int getStateType()
getTransitionsback to summary
public Transition[] getTransitions()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the 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
isNonGreedyExitStateback to summary
public boolean isNonGreedyExitState()
isOptimizedback to summary
public boolean isOptimized()
onlyHasEpsilonTransitionsback to summary
public final boolean onlyHasEpsilonTransitions()
removeOptimizedTransitionback to summary
public void removeOptimizedTransition(int i)
removeTransitionback to summary
public Transition removeTransition(int index)
setOptimizedTransitionback to summary
public void setOptimizedTransition(int i, Transition e)
setRuleIndexback to summary
public void setRuleIndex(int ruleIndex)
setTransitionback to summary
public void setTransition(int i, Transition e)
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
transitionback to summary
public Transition transition(int i)