Package org.antlr.v4.runtime.atn
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 andtransitionsfor various grammar constructs.- Solid edges marked with an ε indicate a required
EpsilonTransition. - Dashed edges indicate locations where any transition derived from
Transitionmight appear. - Dashed nodes are place holders for either a sequence of linked
BasicStatestates 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 Summary
Fields Modifier and Type Field Description ATNatnWhich ATN are we in?static intBASICstatic intBLOCK_ENDstatic intBLOCK_STARTbooleanepsilonOnlyTransitionsstatic intINITIAL_NUM_TRANSITIONSstatic intINVALID_STATE_NUMBERstatic intINVALID_TYPEstatic intLOOP_ENDIntervalSetnextTokenWithinRuleUsed to cache lookahead during parsing, not used during constructionstatic intPLUS_BLOCK_STARTstatic intPLUS_LOOP_BACKstatic intRULE_STARTstatic intRULE_STOPintruleIndexstatic List<String>serializationNamesstatic intSTAR_BLOCK_STARTstatic intSTAR_LOOP_BACKstatic intSTAR_LOOP_ENTRYintstateNumberstatic intTOKEN_STARTprotected List<Transition>transitionsTrack the transitions emanating from this ATN state.
-
Constructor Summary
Constructors Constructor Description ATNState()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddTransition(int index, Transition e)voidaddTransition(Transition e)booleanequals(Object o)intgetNumberOfTransitions()abstract intgetStateType()Transition[]getTransitions()inthashCode()booleanisNonGreedyExitState()booleanonlyHasEpsilonTransitions()TransitionremoveTransition(int index)voidsetRuleIndex(int ruleIndex)voidsetTransition(int i, Transition e)StringtoString()Transitiontransition(int i)
-
-
-
Field Detail
-
INITIAL_NUM_TRANSITIONS
public static final int INITIAL_NUM_TRANSITIONS
- See Also:
- Constant Field Values
-
INVALID_TYPE
public static final int INVALID_TYPE
- See Also:
- Constant Field Values
-
BASIC
public static final int BASIC
- See Also:
- Constant Field Values
-
RULE_START
public static final int RULE_START
- See Also:
- Constant Field Values
-
BLOCK_START
public static final int BLOCK_START
- See Also:
- Constant Field Values
-
PLUS_BLOCK_START
public static final int PLUS_BLOCK_START
- See Also:
- Constant Field Values
-
STAR_BLOCK_START
public static final int STAR_BLOCK_START
- See Also:
- Constant Field Values
-
TOKEN_START
public static final int TOKEN_START
- See Also:
- Constant Field Values
-
RULE_STOP
public static final int RULE_STOP
- See Also:
- Constant Field Values
-
BLOCK_END
public static final int BLOCK_END
- See Also:
- Constant Field Values
-
STAR_LOOP_BACK
public static final int STAR_LOOP_BACK
- See Also:
- Constant Field Values
-
STAR_LOOP_ENTRY
public static final int STAR_LOOP_ENTRY
- See Also:
- Constant Field Values
-
PLUS_LOOP_BACK
public static final int PLUS_LOOP_BACK
- See Also:
- Constant Field Values
-
LOOP_END
public static final int LOOP_END
- See Also:
- Constant Field Values
-
INVALID_STATE_NUMBER
public static final int INVALID_STATE_NUMBER
- See Also:
- Constant Field Values
-
atn
public ATN atn
Which ATN are we in?
-
stateNumber
public int stateNumber
-
ruleIndex
public int ruleIndex
-
epsilonOnlyTransitions
public boolean epsilonOnlyTransitions
-
transitions
protected final List<Transition> transitions
Track the transitions emanating from this ATN state.
-
nextTokenWithinRule
public IntervalSet nextTokenWithinRule
Used to cache lookahead during parsing, not used during construction
-
-
Method Detail
-
isNonGreedyExitState
public boolean isNonGreedyExitState()
-
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)
-
-