public class ParserATNSimulator extends ATNSimulator
Modifier and Type | Field and Description |
---|---|
protected TokenStream |
_input |
protected ParserRuleContext |
_outerContext |
protected int |
_startIndex |
static int |
ATN_failover |
static boolean |
debug |
static boolean |
debug_list_atn_decisions |
DFA[] |
decisionToDFA |
static boolean |
dfa_debug |
protected DoubleKeyMap<PredictionContext,PredictionContext,PredictionContext> |
mergeCache
Each prediction operation uses a cache for merge of prediction contexts.
|
protected PredictionMode |
mode
SLL, LL, or LL + exact ambig detection?
|
protected Parser |
parser |
static int |
predict_calls |
static boolean |
retry_debug |
static int |
retry_with_context |
static int |
retry_with_context_from_dfa |
static int |
retry_with_context_indicates_no_conflict |
static int |
retry_with_context_predicts_same_alt |
atn, ERROR, SERIALIZED_VERSION, sharedContextCache
Constructor and Description |
---|
ParserATNSimulator(ATN atn,
DFA[] decisionToDFA,
PredictionContextCache sharedContextCache)
Testing only!
|
ParserATNSimulator(Parser parser,
ATN atn,
DFA[] decisionToDFA,
PredictionContextCache sharedContextCache) |
Modifier and Type | Method and Description |
---|---|
ATNConfig |
actionTransition(ATNConfig config,
ActionTransition t) |
int |
adaptivePredict(TokenStream input,
int decision,
ParserRuleContext outerContext) |
protected void |
addDFAEdge(DFA dfa,
DFAState from,
int t,
DFAState to) |
protected DFAState |
addDFAState(DFA dfa,
DFAState D)
Add D if not there and return D.
|
protected void |
closure_(ATNConfig config,
ATNConfigSet configs,
Set<ATNConfig> closureBusy,
boolean collectPredicates,
boolean fullCtx,
int depth)
Do the actual work of walking epsilon edges
|
protected void |
closure(ATNConfig config,
ATNConfigSet configs,
Set<ATNConfig> closureBusy,
boolean collectPredicates,
boolean fullCtx) |
protected void |
closureCheckingStopState(ATNConfig config,
ATNConfigSet configs,
Set<ATNConfig> closureBusy,
boolean collectPredicates,
boolean fullCtx,
int depth) |
protected ATNConfigSet |
computeReachSet(ATNConfigSet closure,
int t,
boolean fullCtx) |
ATNConfigSet |
computeStartState(ATNState p,
RuleContext ctx,
boolean fullCtx) |
void |
dumpDeadEndConfigs(NoViableAltException nvae) |
BitSet |
evalSemanticContext(DFAState.PredPrediction[] predPredictions,
ParserRuleContext outerContext,
boolean complete)
Look through a list of predicate/alt pairs, returning alts for the
pairs that win.
|
int |
execATN(DFA dfa,
DFAState s0,
TokenStream input,
int startIndex,
ParserRuleContext outerContext)
Performs ATN simulation to compute a predicted alternative based
upon the remaining input, but also updates the DFA cache to avoid
having to traverse the ATN again for the same input sequence.
|
int |
execATNWithFullContext(DFA dfa,
DFAState D,
ATNConfigSet s0,
TokenStream input,
int startIndex,
ParserRuleContext outerContext,
int SLL_min_alt) |
int |
execDFA(DFA dfa,
DFAState s0,
TokenStream input,
int startIndex,
ParserRuleContext outerContext) |
int |
getAltThatFinishedDecisionEntryRule(ATNConfigSet configs) |
BitSet |
getConflictingAlts(ATNConfigSet configs) |
protected BitSet |
getConflictingAltsOrUniqueAlt(ATNConfigSet configs)
Sam pointed out a problem with the previous definition, v3, of
ambiguous states.
|
ATNConfig |
getEpsilonTarget(ATNConfig config,
Transition t,
boolean collectPredicates,
boolean inContext,
boolean fullCtx) |
String |
getLookaheadName(TokenStream input) |
DFAState.PredPrediction[] |
getPredicatePredictions(BitSet ambigAlts,
SemanticContext[] altToPred) |
PredictionMode |
getPredictionMode() |
SemanticContext[] |
getPredsForAmbigAlts(BitSet ambigAlts,
ATNConfigSet configs,
int nalts) |
ATNState |
getReachableTarget(Transition trans,
int ttype) |
String |
getRuleName(int index) |
String |
getTokenName(int t) |
static int |
getUniqueAlt(ATNConfigSet configs) |
NoViableAltException |
noViableAlt(TokenStream input,
ParserRuleContext outerContext,
ATNConfigSet configs,
int startIndex) |
protected void |
predicateDFAState(DFAState dfaState,
DecisionState decisionState) |
int |
predictATN(DFA dfa,
TokenStream input,
ParserRuleContext outerContext) |
ATNConfig |
predTransition(ATNConfig config,
PredicateTransition pt,
boolean collectPredicates,
boolean inContext,
boolean fullCtx) |
protected ATNConfigSet |
removeAllConfigsNotInRuleStopState(ATNConfigSet configs)
Return a configuration set containing only the configurations from
configs which are in a RuleStopState . |
void |
reportAmbiguity(DFA dfa,
DFAState D,
int startIndex,
int stopIndex,
BitSet ambigAlts,
ATNConfigSet configs)
If context sensitive parsing, we know it's ambiguity not conflict
|
void |
reportAttemptingFullContext(DFA dfa,
ATNConfigSet configs,
int startIndex,
int stopIndex) |
void |
reportContextSensitivity(DFA dfa,
ATNConfigSet configs,
int startIndex,
int stopIndex) |
void |
reset() |
ATNConfig |
ruleTransition(ATNConfig config,
RuleTransition t) |
void |
setPredictionMode(PredictionMode mode) |
checkCondition, checkCondition, deserialize, edgeFactory, getCachedContext, stateFactory, toInt
public static final boolean debug
public static final boolean debug_list_atn_decisions
public static final boolean dfa_debug
public static final boolean retry_debug
public static int ATN_failover
public static int predict_calls
public static int retry_with_context
public static int retry_with_context_indicates_no_conflict
public static int retry_with_context_predicts_same_alt
public static int retry_with_context_from_dfa
protected PredictionMode mode
protected DoubleKeyMap<PredictionContext,PredictionContext,PredictionContext> mergeCache
protected TokenStream _input
protected int _startIndex
protected ParserRuleContext _outerContext
public ParserATNSimulator(@NotNull ATN atn, @NotNull DFA[] decisionToDFA, @NotNull PredictionContextCache sharedContextCache)
public void reset()
reset
in class ATNSimulator
public int adaptivePredict(@NotNull TokenStream input, int decision, @Nullable ParserRuleContext outerContext)
public int predictATN(@NotNull DFA dfa, @NotNull TokenStream input, @Nullable ParserRuleContext outerContext)
public int execDFA(@NotNull DFA dfa, @NotNull DFAState s0, @NotNull TokenStream input, int startIndex, @Nullable ParserRuleContext outerContext)
public int execATN(@NotNull DFA dfa, @NotNull DFAState s0, @NotNull TokenStream input, int startIndex, ParserRuleContext outerContext)
protected void predicateDFAState(DFAState dfaState, DecisionState decisionState)
public int execATNWithFullContext(DFA dfa, DFAState D, @NotNull ATNConfigSet s0, @NotNull TokenStream input, int startIndex, ParserRuleContext outerContext, int SLL_min_alt)
protected ATNConfigSet computeReachSet(ATNConfigSet closure, int t, boolean fullCtx)
@NotNull protected ATNConfigSet removeAllConfigsNotInRuleStopState(@NotNull ATNConfigSet configs)
configs
which are in a RuleStopState
. If all
configurations in configs
are already in a rule stop state, this
method simply returns configs
.configs
- the configuration set to updateconfigs
if all configurations in configs
are in a
rule stop state, otherwise return a new configuration set containing only
the configurations from configs
which are in a rule stop state@NotNull public ATNConfigSet computeStartState(@NotNull ATNState p, @Nullable RuleContext ctx, boolean fullCtx)
@Nullable public ATNState getReachableTarget(@NotNull Transition trans, int ttype)
public SemanticContext[] getPredsForAmbigAlts(@NotNull BitSet ambigAlts, @NotNull ATNConfigSet configs, int nalts)
public DFAState.PredPrediction[] getPredicatePredictions(BitSet ambigAlts, SemanticContext[] altToPred)
public int getAltThatFinishedDecisionEntryRule(ATNConfigSet configs)
public BitSet evalSemanticContext(@NotNull DFAState.PredPrediction[] predPredictions, ParserRuleContext outerContext, boolean complete)
NONE
predicate indicates an alt containing an
unpredicated config which behaves as "always true." If !complete
then we stop at the first predicate that evaluates to true. This
includes pairs with null predicates.protected void closure(@NotNull ATNConfig config, @NotNull ATNConfigSet configs, @NotNull Set<ATNConfig> closureBusy, boolean collectPredicates, boolean fullCtx)
protected void closureCheckingStopState(@NotNull ATNConfig config, @NotNull ATNConfigSet configs, @NotNull Set<ATNConfig> closureBusy, boolean collectPredicates, boolean fullCtx, int depth)
protected void closure_(@NotNull ATNConfig config, @NotNull ATNConfigSet configs, @NotNull Set<ATNConfig> closureBusy, boolean collectPredicates, boolean fullCtx, int depth)
@Nullable public ATNConfig getEpsilonTarget(@NotNull ATNConfig config, @NotNull Transition t, boolean collectPredicates, boolean inContext, boolean fullCtx)
@NotNull public ATNConfig actionTransition(@NotNull ATNConfig config, @NotNull ActionTransition t)
@Nullable public ATNConfig predTransition(@NotNull ATNConfig config, @NotNull PredicateTransition pt, boolean collectPredicates, boolean inContext, boolean fullCtx)
@NotNull public ATNConfig ruleTransition(@NotNull ATNConfig config, @NotNull RuleTransition t)
public BitSet getConflictingAlts(ATNConfigSet configs)
protected BitSet getConflictingAltsOrUniqueAlt(ATNConfigSet configs)
public String getLookaheadName(TokenStream input)
public void dumpDeadEndConfigs(@NotNull NoViableAltException nvae)
@NotNull public NoViableAltException noViableAlt(@NotNull TokenStream input, @NotNull ParserRuleContext outerContext, @NotNull ATNConfigSet configs, int startIndex)
public static int getUniqueAlt(@NotNull ATNConfigSet configs)
protected void addDFAEdge(@NotNull DFA dfa, @Nullable DFAState from, int t, @Nullable DFAState to)
protected DFAState addDFAState(@NotNull DFA dfa, @NotNull DFAState D)
public void reportAttemptingFullContext(DFA dfa, ATNConfigSet configs, int startIndex, int stopIndex)
public void reportContextSensitivity(DFA dfa, ATNConfigSet configs, int startIndex, int stopIndex)
public void reportAmbiguity(@NotNull DFA dfa, DFAState D, int startIndex, int stopIndex, @NotNull BitSet ambigAlts, @NotNull ATNConfigSet configs)
public void setPredictionMode(PredictionMode mode)
public PredictionMode getPredictionMode()
Copyright © 1992-2013 ANTLR. All Rights Reserved.