Top Fields Constructors Methods
org.antlr.v4.runtime.atn

public Class ProfilingATNSimulator

extends ParserATNSimulator
Class Inheritance
Imports
org.antlr.v4.runtime.Parser, .ParserRuleContext, .TokenStream, org.antlr.v4.runtime.dfa.DFA, .DFAState, java.util.BitSet

Since
4.3

Field Summary

Modifier and TypeField and Description
protected int
protected int
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.

protected int
protected DFAState
protected final DecisionInfo[]
protected int
Inherited from org.antlr.v4.runtime.atn.ParserATNSimulator:
_dfa_input_outerContext_startIndexdebugdecisionToDFAdfa_debugmergeCacheparserretry_debugtrace_atn_simTURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
protected ATNConfigSet
protected DFAState
computeTargetState(DFA
The DFA
dfa
,
DFAState
The current DFA state
previousD
,
int
The next input symbol
t
)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.computeTargetState.

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
The semantic context to evaluate
pred
,
ParserRuleContext
The parser context in which to evaluate the semantic context
parserCallStack
,
int
The alternative which is guarded by pred
alt
,
boolean
true if the evaluation is occurring during LL prediction; otherwise, false if the evaluation is occurring during SLL prediction
fullCtx
)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.evalSemanticContext.

Evaluate a semantic context within a specific parser context.
public DFAState
public DecisionInfo[]
protected DFAState
getExistingTargetState(DFAState
The current DFA state
previousD
,
int
The next input symbol
t
)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.getExistingTargetState.

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)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.reportAmbiguity.

If context sensitive parsing, we know it's ambiguity not conflict
protected void
protected void
reportContextSensitivity(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.reportContextSensitivity.

Inherited from org.antlr.v4.runtime.atn.ParserATNSimulator:
actionTransitionaddDFAEdgeaddDFAStateapplyPrecedenceFiltercanDropLoopEntryEdgeInLeftRecursiveRuleclearDFAclosureclosure_closureCheckingStopStatecomputeStartStatedumpDeadEndConfigsevalSemanticContextexecATNexecATNWithFullContextgetAltThatFinishedDecisionEntryRulegetConflictingAltsgetConflictingAltsOrUniqueAltgetEpsilonTargetgetLookaheadNamegetParsergetPredicatePredictionsgetPredictionModegetPredsForAmbigAltsgetReachableTargetgetRuleNamegetSafeEnvgetSynValidOrSemInvalidAltThatFinishedDecisionEntryRulegetTokenNamegetUniqueAltnoViableAltprecedenceTransitionpredicateDFAStatepredTransitionremoveAllConfigsNotInRuleStopStateresetruleTransitionsetPredictionModesplitAccordingToSemanticValidity

Field Detail

_llStopIndexback to summary
protected int _llStopIndex
_sllStopIndexback to summary
protected int _sllStopIndex
conflictingAltResolvedBySLLback to summary
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.

currentDecisionback to summary
protected int currentDecision
currentStateback to summary
protected DFAState currentState
decisionsback to summary
protected final DecisionInfo[] decisions
numDecisionsback to summary
protected int numDecisions

Constructor Detail

ProfilingATNSimulatorback to summary
public ProfilingATNSimulator(Parser parser)

Method Detail

adaptivePredictback to summary
public int adaptivePredict(TokenStream input, int decision, ParserRuleContext outerContext)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict.

Annotations
@Override
computeReachSetback to summary
protected ATNConfigSet computeReachSet(ATNConfigSet closure, int t, boolean fullCtx)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.computeReachSet.

Annotations
@Override
computeTargetStateback to summary
protected DFAState computeTargetState(DFA dfa, DFAState previousD, int t)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.computeTargetState.

Doc from org.antlr.v4.runtime.atn.ParserATNSimulator.computeTargetState.

Compute a target state for an edge in the DFA, and attempt to add the computed state and corresponding edge to the DFA.

Parameters
dfa:DFA

The DFA

previousD:DFAState

The current DFA state

t:int

The next input symbol

Returns:DFAState

The computed target DFA state for the given input symbol t. If t does not lead to a valid DFA state, this method returns ERROR.

Annotations
@Override
evalSemanticContextback to summary
protected boolean evalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt, boolean fullCtx)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.evalSemanticContext.

Doc from org.antlr.v4.runtime.atn.ParserATNSimulator.evalSemanticContext.

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 and SemanticContext.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.
Parameters
pred:SemanticContext

The semantic context to evaluate

parserCallStack:ParserRuleContext

The parser context in which to evaluate the semantic context

alt:int

The alternative which is guarded by pred

fullCtx:boolean

true if the evaluation is occurring during LL prediction; otherwise, false if the evaluation is occurring during SLL prediction

Annotations
@Override
getCurrentStateback to summary
public DFAState getCurrentState()
getDecisionInfoback to summary
public DecisionInfo[] getDecisionInfo()
getExistingTargetStateback to summary
protected DFAState getExistingTargetState(DFAState previousD, int t)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.getExistingTargetState.

Doc from org.antlr.v4.runtime.atn.ParserATNSimulator.getExistingTargetState.

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 returns null.

Parameters
previousD:DFAState

The current DFA state

t:int

The next input symbol

Returns:DFAState

The existing target DFA state for the given input symbol t, or null if the target state for this edge is not already cached

Annotations
@Override
reportAmbiguityback to summary
protected void reportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact, BitSet ambigAlts, ATNConfigSet configs)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.reportAmbiguity.

Doc from org.antlr.v4.runtime.atn.ParserATNSimulator.reportAmbiguity.

If context sensitive parsing, we know it's ambiguity not conflict

Annotations
@Override
reportAttemptingFullContextback to summary
protected void reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, ATNConfigSet configs, int startIndex, int stopIndex)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.reportAttemptingFullContext.

Annotations
@Override
reportContextSensitivityback to summary
protected void reportContextSensitivity(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex)

Overrides org.antlr.v4.runtime.atn.ParserATNSimulator.reportContextSensitivity.

Annotations
@Override