ATN

Class implementation adapted from Java code

Constructors

this
this(ATNType grammarType, int maxTokenType)

Used for runtime deserialization of ATNs from strings

Members

Functions

addState
void addState(ATNState state)
Undocumented in source. Be warned that the author may not have intended to support it.
defineDecisionState
int defineDecisionState(DecisionState s)
Undocumented in source. Be warned that the author may not have intended to support it.
getDecisionState
DecisionState getDecisionState(int decision)
Undocumented in source. Be warned that the author may not have intended to support it.
getExpectedTokens
IntervalSet getExpectedTokens(int stateNumber, RuleContext context)

Computes the set of input symbols which could follow ATN state number {@code stateNumber} in the specified full {@code context}. This method considers the complete parser context, but does not evaluate semantic predicates (i.e. all predicates encountered during the calculation are assumed true). If a path in the ATN exists from the starting state to the {@link RuleStopState} of the outermost context without matching any symbols, {@link Token#EOF} is added to the returned set.

getNumberOfDecisions
int getNumberOfDecisions()
Undocumented in source. Be warned that the author may not have intended to support it.
nextTokens
IntervalSet nextTokens(ATNState s, RuleContext ctx)

Compute the set of valid tokens that can occur starting in state {@code s}. If {@code ctx} is null, the set of tokens will not include what can follow the rule surrounding {@code s}. In other words, the set will be restricted to tokens reachable staying within {@code s}'s rule.

nextTokens
IntervalSet nextTokens(ATNState s)

Compute the set of valid tokens that can occur starting in {@code s} and staying in same rule. {@link Token#EPSILON} is in set if we reach end of rule.

removeState
void removeState(ATNState state)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

INVALID_ALT_NUMBER
enum int INVALID_ALT_NUMBER;
Undocumented in source.
decisionToState
DecisionState[] decisionToState;

Each subrule/rule is a decision point and we must track them so we can go back later and build DFA predictors for them. This includes all the rules, subrules, optional blocks, ()+, ()* etc...

grammarType
ATNType grammarType;

The type of the ATN.

lexerActions
LexerAction[] lexerActions;

For lexer ATNs, this is an array of {@link LexerAction} objects which may be referenced by action transitions in the ATN.

maxTokenType
int maxTokenType;

The maximum value for any symbol recognized by a transition in the ATN.

modeNameToStartState
TokensStartState[string] modeNameToStartState;
Undocumented in source.
modeToStartState
TokensStartState[] modeToStartState;
Undocumented in source.
ruleToStartState
RuleStartState[] ruleToStartState;

Maps from rule index to starting state number.

ruleToStopState
RuleStopState[] ruleToStopState;

Maps from rule index to stop state number.

ruleToTokenType
int[] ruleToTokenType;

For lexer ATNs, this maps the rule index to the resulting token type. For parser ATNs, this maps the rule index to the generated bypass token type if the {@link ATNDeserializationOptions#isGenerateRuleBypassTransitions} deserialization option was specified; otherwise, this is {@code null}.

states
ATNState[] states;
Undocumented in source.

Meta