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 int
protected int
protected int
At 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 int
protected DFAState
protected final DecisionInfo[]
protected int
Fields inherited from class org.antlr.v4.runtime.atn.ParserATNSimulator
_dfa, _input, _outerContext, _startIndex, debug, debug_list_atn_decisions, decisionToDFA, dfa_debug, mergeCache, parser, retry_debug, TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT
Fields inherited from class org.antlr.v4.runtime.atn.ATNSimulator
atn, ERROR, SERIALIZED_UUID, SERIALIZED_VERSION, sharedContextCache
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
adaptivePredict
(TokenStream input, int decision, ParserRuleContext outerContext) protected ATNConfigSet
computeReachSet
(ATNConfigSet closure, int t, boolean fullCtx) protected DFAState
computeTargetState
(DFA dfa, DFAState previousD, int t) Compute a target state for an edge in the DFA, and attempt to add the computed state and corresponding edge to the DFA.protected boolean
evalSemanticContext
(SemanticContext pred, ParserRuleContext parserCallStack, int alt, boolean fullCtx) Evaluate a semantic context within a specific parser context.protected DFAState
getExistingTargetState
(DFAState previousD, int t) Get an existing target state for an edge in the DFA.protected void
reportAmbiguity
(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 void
reportAttemptingFullContext
(DFA dfa, BitSet conflictingAlts, ATNConfigSet configs, int startIndex, int stopIndex) protected void
reportContextSensitivity
(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex) Methods inherited from class org.antlr.v4.runtime.atn.ParserATNSimulator
actionTransition, addDFAEdge, addDFAState, applyPrecedenceFilter, canDropLoopEntryEdgeInLeftRecursiveRule, clearDFA, closure, closure_, closureCheckingStopState, computeStartState, dumpDeadEndConfigs, evalSemanticContext, execATN, execATNWithFullContext, getAltThatFinishedDecisionEntryRule, getConflictingAlts, getConflictingAltsOrUniqueAlt, getEpsilonTarget, getLookaheadName, getParser, getPredicatePredictions, getPredictionMode, getPredsForAmbigAlts, getReachableTarget, getRuleName, getSafeEnv, getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule, getTokenName, getUniqueAlt, noViableAlt, precedenceTransition, predicateDFAState, predTransition, removeAllConfigsNotInRuleStopState, reset, ruleTransition, setPredictionMode, splitAccordingToSemanticValidity
Methods inherited from class org.antlr.v4.runtime.atn.ATNSimulator
checkCondition, checkCondition, deserialize, edgeFactory, getCachedContext, getSharedContextCache, stateFactory, toInt, toInt32, toLong, toUUID
-
Field Details
-
decisions
-
numDecisions
protected int numDecisions -
_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:
adaptivePredict
in classParserATNSimulator
-
getExistingTargetState
Description copied from class:ParserATNSimulator
Get 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:
getExistingTargetState
in classParserATNSimulator
- Parameters:
previousD
- The current DFA statet
- The next input symbol- Returns:
- The existing target DFA state for the given input symbol
t
, ornull
if the target state for this edge is not already cached
-
computeTargetState
Description copied from class:ParserATNSimulator
Compute a target state for an edge in the DFA, and attempt to add the computed state and corresponding edge to the DFA.- Overrides:
computeTargetState
in classParserATNSimulator
- Parameters:
dfa
- The DFApreviousD
- The current DFA statet
- The next input symbol- Returns:
- The computed target DFA state for the given input symbol
t
. Ift
does not lead to a valid DFA state, this method returnsATNSimulator.ERROR
.
-
computeReachSet
- Overrides:
computeReachSet
in classParserATNSimulator
-
evalSemanticContext
protected boolean evalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt, boolean fullCtx) Description copied from class:ParserATNSimulator
Evaluate 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.AND
andSemanticContext.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:
evalSemanticContext
in classParserATNSimulator
- Parameters:
pred
- The semantic context to evaluateparserCallStack
- The parser context in which to evaluate the semantic contextalt
- The alternative which is guarded bypred
fullCtx
-true
if the evaluation is occurring during LL prediction; otherwise,false
if the evaluation is occurring during SLL prediction
- Precedence predicates (represented by
-
reportAttemptingFullContext
protected void reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, ATNConfigSet configs, int startIndex, int stopIndex) - Overrides:
reportAttemptingFullContext
in classParserATNSimulator
-
reportContextSensitivity
protected void reportContextSensitivity(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex) - Overrides:
reportContextSensitivity
in classParserATNSimulator
-
reportAmbiguity
protected void reportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact, BitSet ambigAlts, ATNConfigSet configs) Description copied from class:ParserATNSimulator
If context sensitive parsing, we know it's ambiguity not conflict- Overrides:
reportAmbiguity
in classParserATNSimulator
-
getDecisionInfo
-
getCurrentState
-