Package org.antlr.v4.runtime.atn
Class ProfilingATNSimulator
java.lang.Object
org.antlr.v4.runtime.atn.ATNSimulator
org.antlr.v4.runtime.atn.ParserATNSimulator
org.antlr.v4.runtime.atn.ProfilingATNSimulator
- Since:
- 4.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TokenStreamprotected intprotected intprotected intprotected intAt the point of LL failover, we record how SLL would resolve the conflict so that we can determine whether or not a decision / input pair is context-sensitive.protected intprotected SimulatorStateprotected final DecisionInfo[]protected intFields inherited from class org.antlr.v4.runtime.atn.ParserATNSimulator
always_try_local_context, debug, dfa_debug, enable_global_context_dfa, force_global_context, optimize_hidden_conflicted_configs, optimize_ll1, optimize_tail_calls, optimize_unique_closure, parser, reportAmbiguities, retry_debug, tail_call_preserves_sll, treat_sllk1_conflict_as_ambiguity, userWantsCtxSensitiveFields inherited from class org.antlr.v4.runtime.atn.ATNSimulator
atn, ERROR, RULE_LF_VARIANT_MARKER, RULE_NOLF_VARIANT_MARKER, RULE_VARIANT_DELIMITER, SERIALIZED_UUID, SERIALIZED_VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintadaptivePredict(TokenStream input, int decision, ParserRuleContext outerContext) protected SimulatorStatecomputeReachSet(DFA dfa, SimulatorState previous, int t, PredictionContextCache contextCache) protected SimulatorStatecomputeStartState(DFA dfa, ParserRuleContext globalContext, boolean useContext) protected Tuple2<DFAState,ParserRuleContext> computeTargetState(DFA dfa, DFAState s, ParserRuleContext remainingGlobalContext, int t, boolean useContext, PredictionContextCache contextCache) Compute a target state for an edge in the DFA, and attempt to add the computed state and corresponding edge to the DFA.protected booleanevalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt) Evaluate a semantic context within a specific parser context.Simulator position for the prediction most recently in flight (or just completed).protected DFAStategetExistingTargetState(DFAState previousD, int t) Get an existing target state for an edge in the DFA.protected SimulatorStategetStartState(DFA dfa, TokenStream input, ParserRuleContext outerContext, boolean useContext) Local- or full-context DFA start, ornullif it is not yet built.protected voidreportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact, BitSet ambigAlts, ATNConfigSet configs) If context sensitive parsing, we know it's ambiguity not conflictprotected voidreportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, SimulatorState conflictState, int startIndex, int stopIndex) protected voidreportContextSensitivity(DFA dfa, int prediction, SimulatorState acceptState, int startIndex, int stopIndex) protected booleanWhetherParserATNSimulator.adaptivePredict(org.antlr.v4.runtime.TokenStream, int, org.antlr.v4.runtime.ParserRuleContext)must callParserATNSimulator.getStartState(org.antlr.v4.runtime.dfa.DFA, org.antlr.v4.runtime.TokenStream, org.antlr.v4.runtime.ParserRuleContext, boolean)so a subclass can observe the start snapshot.Methods inherited from class org.antlr.v4.runtime.atn.ParserATNSimulator
actionTransition, adaptivePredict, addDFAContextState, addDFAEdge, addDFAEdge, addDFAState, applyPrecedenceFilter, closure, closure, configWithAltAtStopState, createDFAState, dumpDeadEndConfigs, epsilonClosure, evalSemanticContext, execATN, execDFA, getConflictingAltsFromConfigSet, getDfaForClosure, getEpsilonTarget, getLookaheadName, getParser, getPredicatePredictions, getPredictionMode, getPredsForAmbigAlts, getReachableTarget, getReturnState, getRuleName, getTokenName, getUniqueAlt, handleNoViableAlt, isAcceptState, noViableAlt, precedenceTransition, predicateDFAState, predTransition, removeAllConfigsNotInRuleStopState, reset, retainedReachConfigs, ruleTransition, setPredictionMode, skipTailCallsMethods inherited from class org.antlr.v4.runtime.atn.ATNSimulator
checkCondition, checkCondition, clearDFA, deserialize, edgeFactory, stateFactory, toInt, toInt32, toLong, toUUID
-
Field Details
-
decisions
-
numDecisions
protected int numDecisions -
_input
-
_startIndex
protected int _startIndex -
_sllStopIndex
protected int _sllStopIndex -
_llStopIndex
protected int _llStopIndex -
currentDecision
protected int currentDecision -
currentState
-
conflictingAltResolvedBySLL
protected int conflictingAltResolvedBySLLAt the point of LL failover, we record how SLL would resolve the conflict so that we can determine whether or not a decision / input pair is context-sensitive. If LL gives a different result than SLL's predicted alternative, we have a context sensitivity for sure. The converse is not necessarily true, however. It's possible that after conflict resolution chooses minimum alternatives, SLL could get the same answer as LL. Regardless of whether or not the result indicates an ambiguity, it is not treated as a context sensitivity because LL prediction was not required in order to produce a correct prediction for this decision and input sequence. It may in fact still be a context sensitivity but we don't know by looking at the minimum alternatives for the current input.
-
-
Constructor Details
-
ProfilingATNSimulator
-
-
Method Details
-
adaptivePredict
- Overrides:
adaptivePredictin classParserATNSimulator
-
snapshotStartState
protected boolean snapshotStartState()Description copied from class:ParserATNSimulatorWhetherParserATNSimulator.adaptivePredict(org.antlr.v4.runtime.TokenStream, int, org.antlr.v4.runtime.ParserRuleContext)must callParserATNSimulator.getStartState(org.antlr.v4.runtime.dfa.DFA, org.antlr.v4.runtime.TokenStream, org.antlr.v4.runtime.ParserRuleContext, boolean)so a subclass can observe the start snapshot. Production returnsfalseand inlines the warm SLL DFA start.- Overrides:
snapshotStartStatein classParserATNSimulator
-
getStartState
protected SimulatorState getStartState(DFA dfa, TokenStream input, ParserRuleContext outerContext, boolean useContext) Description copied from class:ParserATNSimulatorLocal- or full-context DFA start, ornullif it is not yet built. Returns a newSimulatorState(ornull); never a recycled instance.- Overrides:
getStartStatein classParserATNSimulator
-
computeStartState
protected SimulatorState computeStartState(DFA dfa, ParserRuleContext globalContext, boolean useContext) - Overrides:
computeStartStatein classParserATNSimulator
-
computeReachSet
protected SimulatorState computeReachSet(DFA dfa, SimulatorState previous, int t, PredictionContextCache contextCache) - Overrides:
computeReachSetin classParserATNSimulator
-
getExistingTargetState
Description copied from class:ParserATNSimulatorGet an existing target state for an edge in the DFA. If the target state for the edge has not yet been computed or is otherwise not available, this method returnsnull.- Overrides:
getExistingTargetStatein classParserATNSimulator- Parameters:
previousD- The current DFA statet- The next input symbol- Returns:
- The existing target DFA state for the given input symbol
t, ornullif the target state for this edge is not already cached
-
computeTargetState
protected Tuple2<DFAState,ParserRuleContext> computeTargetState(DFA dfa, DFAState s, ParserRuleContext remainingGlobalContext, int t, boolean useContext, PredictionContextCache contextCache) Description copied from class:ParserATNSimulatorCompute a target state for an edge in the DFA, and attempt to add the computed state and corresponding edge to the DFA.Delegates to package-private
ReachComputation, which owns the retained reach / intermediate sets and the full-context config view.- Overrides:
computeTargetStatein classParserATNSimulator- Parameters:
dfa- the DFA owning this decisions- the current DFA stateremainingGlobalContext- remaining full context, ornullt- the next input symboluseContext- whether full-context prediction is activecontextCache- prediction-context cache for this simulation- Returns:
- The computed target DFA state for the given input symbol
t. Iftdoes not lead to a valid DFA state, this method returnsATNSimulator.ERROR.
-
evalSemanticContext
protected boolean evalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt) Description copied from class:ParserATNSimulatorEvaluate a semantic context within a specific parser context.This method might not be called for every semantic context evaluated during the prediction process. In particular, we currently do not evaluate the following but it may change in the future:
- Precedence predicates (represented by
SemanticContext.PrecedencePredicate) are not currently evaluated through this method. - Operator predicates (represented by
SemanticContext.ANDandSemanticContext.OR) are evaluated as a single semantic context, rather than evaluating the operands individually. Implementations which require evaluation results from individual predicates should override this method to explicitly handle evaluation of the operands within operator predicates.
- Overrides:
evalSemanticContextin classParserATNSimulator- Parameters:
pred- The semantic context to evaluateparserCallStack- The parser context in which to evaluate the semantic contextalt- The alternative which is guarded bypred
- Precedence predicates (represented by
-
reportContextSensitivity
protected void reportContextSensitivity(DFA dfa, int prediction, SimulatorState acceptState, int startIndex, int stopIndex) - Overrides:
reportContextSensitivityin classParserATNSimulator
-
reportAttemptingFullContext
protected void reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, SimulatorState conflictState, int startIndex, int stopIndex) - Overrides:
reportAttemptingFullContextin classParserATNSimulator
-
reportAmbiguity
protected void reportAmbiguity(@NotNull DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact, @NotNull BitSet ambigAlts, @NotNull ATNConfigSet configs) Description copied from class:ParserATNSimulatorIf context sensitive parsing, we know it's ambiguity not conflict- Overrides:
reportAmbiguityin classParserATNSimulator
-
getDecisionInfo
-
getCurrentState
Simulator position for the prediction most recently in flight (or just completed). The returned object is not reused; later predictions do not mutate a previously returned instance.
-