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, org.antlr.v4.runtime.misc.NotNull, .Tuple2, java.util.BitSet

Since
4.3

Field Summary

Modifier and TypeField and Description
protected TokenStream
protected int
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 SimulatorState
protected final DecisionInfo[]
protected int
Inherited from org.antlr.v4.runtime.atn.ParserATNSimulator:
always_try_local_contextdebugdfa_debugenable_global_context_dfaforce_global_contextoptimize_hidden_conflicted_configsoptimize_ll1optimize_tail_callsoptimize_unique_closureparserreportAmbiguitiesretry_debugtail_call_preserves_slltreat_sllk1_conflict_as_ambiguityuserWantsCtxSensitive

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
protected SimulatorState
protected SimulatorState
protected Tuple2<DFAState, ParserRuleContext>
computeTargetState(DFA dfa, DFAState
The current DFA state
s
,
ParserRuleContext remainingGlobalContext, int
The next input symbol
t
,
boolean useContext, PredictionContextCache contextCache)

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
)

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

Evaluate a semantic context within a specific parser context.
public SimulatorState
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 SimulatorState
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
reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, SimulatorState conflictState, int startIndex, int stopIndex)

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

protected void
reportContextSensitivity(DFA dfa, int prediction, SimulatorState acceptState, int startIndex, int stopIndex)

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

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

Field Detail

_inputback to summary
protected TokenStream _input
_llStopIndexback to summary
protected int _llStopIndex
_sllStopIndexback to summary
protected int _sllStopIndex
_startIndexback to summary
protected int _startIndex
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 SimulatorState 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 SimulatorState computeReachSet(DFA dfa, SimulatorState previous, int t, PredictionContextCache contextCache)

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

Annotations
@Override
computeStartStateback to summary
protected SimulatorState computeStartState(DFA dfa, ParserRuleContext globalContext, boolean useContext)

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

Annotations
@Override
computeTargetStateback to summary
protected Tuple2<DFAState, ParserRuleContext> computeTargetState(DFA dfa, DFAState s, ParserRuleContext remainingGlobalContext, int t, boolean useContext, PredictionContextCache contextCache)

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
s:DFAState

The current DFA state

t:int

The next input symbol

Returns:Tuple2<DFAState, ParserRuleContext>

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)

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

Annotations
@Override
getCurrentStateback to summary
public SimulatorState 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
getStartStateback to summary
protected SimulatorState getStartState(DFA dfa, TokenStream input, ParserRuleContext outerContext, boolean useContext)

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

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, SimulatorState conflictState, int startIndex, int stopIndex)

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

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

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

Annotations
@Override