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
-
public class ProfilingATNSimulator extends ParserATNSimulator
- Since:
- 4.3
-
-
Field Summary
Fields Modifier and Type Field Description protected int_llStopIndexprotected int_sllStopIndexprotected intconflictingAltResolvedBySLLAt 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 intcurrentDecisionprotected DFAStatecurrentStateprotected DecisionInfo[]decisionsprotected intnumDecisions-
Fields inherited from class org.antlr.v4.runtime.atn.ParserATNSimulator
_dfa, _input, _outerContext, _startIndex, debug, decisionToDFA, dfa_debug, mergeCache, parser, retry_debug, trace_atn_sim, TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT
-
Fields inherited from class org.antlr.v4.runtime.atn.ATNSimulator
atn, ERROR, sharedContextCache
-
-
Constructor Summary
Constructors Constructor Description ProfilingATNSimulator(Parser parser)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intadaptivePredict(TokenStream input, int decision, ParserRuleContext outerContext)protected ATNConfigSetcomputeReachSet(ATNConfigSet closure, int t, boolean fullCtx)protected DFAStatecomputeTargetState(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 booleanevalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt, boolean fullCtx)Evaluate a semantic context within a specific parser context.DFAStategetCurrentState()DecisionInfo[]getDecisionInfo()protected DFAStategetExistingTargetState(DFAState previousD, int t)Get an existing target state for an edge in the DFA.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, ATNConfigSet configs, int startIndex, int stopIndex)protected voidreportContextSensitivity(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
getCachedContext, getSharedContextCache
-
-
-
-
Field Detail
-
decisions
protected final DecisionInfo[] decisions
-
numDecisions
protected int numDecisions
-
_sllStopIndex
protected int _sllStopIndex
-
_llStopIndex
protected int _llStopIndex
-
currentDecision
protected int currentDecision
-
currentState
protected DFAState currentState
-
conflictingAltResolvedBySLL
protected int conflictingAltResolvedBySLL
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. 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 Detail
-
ProfilingATNSimulator
public ProfilingATNSimulator(Parser parser)
-
-
Method Detail
-
adaptivePredict
public int adaptivePredict(TokenStream input, int decision, ParserRuleContext outerContext)
- Overrides:
adaptivePredictin classParserATNSimulator
-
getExistingTargetState
protected DFAState getExistingTargetState(DFAState previousD, int t)
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 DFAState computeTargetState(DFA dfa, DFAState previousD, int t)
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.- Overrides:
computeTargetStatein 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. Iftdoes not lead to a valid DFA state, this method returnsATNSimulator.ERROR.
-
computeReachSet
protected ATNConfigSet computeReachSet(ATNConfigSet closure, int t, boolean fullCtx)
- Overrides:
computeReachSetin classParserATNSimulator
-
evalSemanticContext
protected boolean evalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt, boolean fullCtx)
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 bypredfullCtx-trueif the evaluation is occurring during LL prediction; otherwise,falseif 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:
reportAttemptingFullContextin classParserATNSimulator
-
reportContextSensitivity
protected void reportContextSensitivity(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex)
- Overrides:
reportContextSensitivityin classParserATNSimulator
-
reportAmbiguity
protected void reportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact, BitSet ambigAlts, ATNConfigSet configs)
Description copied from class:ParserATNSimulatorIf context sensitive parsing, we know it's ambiguity not conflict- Overrides:
reportAmbiguityin classParserATNSimulator
-
getDecisionInfo
public DecisionInfo[] getDecisionInfo()
-
getCurrentState
public DFAState getCurrentState()
-
-