public class ATN extends Object
Modifier and Type | Field and Description |
---|---|
List<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.
|
ATNType |
grammarType
The type of the ATN.
|
static int |
INVALID_ALT_NUMBER |
LexerAction[] |
lexerActions
For lexer ATNs, this is an array of
LexerAction objects which may
be referenced by action transitions in the ATN. |
int |
maxTokenType
The maximum value for any symbol recognized by a transition in the ATN.
|
Map<String,TokensStartState> |
modeNameToStartState |
List<TokensStartState> |
modeToStartState |
RuleStartState[] |
ruleToStartState
Maps from rule index to starting state number.
|
RuleStopState[] |
ruleToStopState
Maps from rule index to stop state number.
|
int[] |
ruleToTokenType
For lexer ATNs, this maps the rule index to the resulting token type.
|
List<ATNState> |
states |
Constructor and Description |
---|
ATN(ATNType grammarType,
int maxTokenType)
Used for runtime deserialization of ATNs from strings
|
Modifier and Type | Method and Description |
---|---|
void |
addState(ATNState state) |
int |
defineDecisionState(DecisionState s) |
DecisionState |
getDecisionState(int decision) |
IntervalSet |
getExpectedTokens(int stateNumber,
RuleContext context)
Computes the set of input symbols which could follow ATN state number
stateNumber in the specified full context . |
int |
getNumberOfDecisions() |
IntervalSet |
nextTokens(ATNState s)
Compute the set of valid tokens that can occur starting in
s and
staying in same rule. |
IntervalSet |
nextTokens(ATNState s,
RuleContext ctx)
Compute the set of valid tokens that can occur starting in state
s . |
void |
removeState(ATNState state) |
public static final int INVALID_ALT_NUMBER
public final List<DecisionState> decisionToState
public RuleStartState[] ruleToStartState
public RuleStopState[] ruleToStopState
public final Map<String,TokensStartState> modeNameToStartState
public final ATNType grammarType
public final int maxTokenType
public int[] ruleToTokenType
ATNDeserializationOptions.isGenerateRuleBypassTransitions()
deserialization option was specified; otherwise, this is null
.public LexerAction[] lexerActions
LexerAction
objects which may
be referenced by action transitions in the ATN.public final List<TokensStartState> modeToStartState
public ATN(ATNType grammarType, int maxTokenType)
public IntervalSet nextTokens(ATNState s, RuleContext ctx)
s
.
If ctx
is null, the set of tokens will not include what can follow
the rule surrounding s
. In other words, the set will be
restricted to tokens reachable staying within s
's rule.public IntervalSet nextTokens(ATNState s)
s
and
staying in same rule. Token.EPSILON
is in set if we reach end of
rule.public void addState(ATNState state)
public void removeState(ATNState state)
public int defineDecisionState(DecisionState s)
public DecisionState getDecisionState(int decision)
public int getNumberOfDecisions()
public IntervalSet getExpectedTokens(int stateNumber, RuleContext context)
stateNumber
in the specified full 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
RuleStopState
of the outermost context without matching any
symbols, Token.EOF
is added to the returned set.
If context
is null
, it is treated as RuleContext.EMPTY
.
stateNumber
- the ATN state numbercontext
- the full parse contextIllegalArgumentException
- if the ATN does not contain a state with
number stateNumber
Copyright © 1992–2018 ANTLR. All rights reserved.