ProfilingATNSimulator class
Properties
-
atn
→ ATN
-
finalinherited
-
conflictingAltResolvedBySLL
↔ 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.
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.
getter/setter pair
-
currentDecision
↔ int
-
getter/setter pair
-
currentState
↔ DFAState?
-
getter/setter pair
-
decisionInfo
→ List<DecisionInfo>
-
no setter
-
decisions
↔ List<DecisionInfo>
-
getter/setter pair
-
decisionToDFA
→ List<DFA>
-
finalinherited
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
input
↔ TokenStream
-
getter/setter pairinherited
-
mergeCache
↔ Map<Pair<PredictionContext, PredictionContext>, PredictionContext>?
-
Each prediction operation uses a cache for merge of prediction contexts.
Don't keep around as it wastes huge amounts of memory. DoubleKeyMap
isn't synchronized but we're ok since two threads shouldn't reuse same
parser/atnsim object because it can only handle one input at a time.
This maps graphs a and b to merged result c. (a,b)→c. We can avoid
the merge if we ever see a and b again. Note that (b,a)→c should
also be examined during cache lookup.
getter/setter pairinherited
-
numDecisions
↔ int
-
getter/setter pair
-
parser
→ Parser
-
finalinherited
-
predictionMode
↔ PredictionMode
-
SLL, LL, or LL + exact ambig detection? */
getter/setter pairinherited
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
-
sharedContextCache
→ PredictionContextCache?
-
The context cache maps all PredictionContext objects that are equals()
to a single cached copy. This cache is shared across all contexts
in all ATNConfigs in all DFA states. We rebuild each ATNConfigSet
to use only cached nodes/graphs in addDFAState(). We don't want to
fill this during closure() since there are lots of contexts that
pop up but are not used ever again. It also greatly slows down closure().
finalinherited
-
startIndex
↔ int
-
getter/setter pairinherited
Methods
-
actionTransition(ATNConfig config, ActionTransition t)
→ ATNConfig
-
inherited
-
adaptivePredict(TokenStream input, int decision, ParserRuleContext? outerContext)
→ int
-
override
-
addDFAEdge(DFA dfa, DFAState? from, int t, DFAState to)
→ DFAState?
-
Add an edge to the DFA, if possible. This method calls
{@link #addDFAState} to ensure the
to
state is present in the
DFA. If from
is null, or if t
is outside the
range of edges that can be represented in the DFA tables, this method
returns without adding the edge to the DFA.
inherited
-
addDFAState(DFA dfa, DFAState D)
→ DFAState
-
Add state
D
to the DFA if it is not already present, and return
the actual instance stored in the DFA. If a state equivalent to D
is already in the DFA, the existing state is returned. Otherwise this
method returns D
after adding it to the DFA.
inherited
-
applyPrecedenceFilter(ATNConfigSet configs)
→ ATNConfigSet
-
This method transforms the start state computed by
{@link #computeStartState} to the special start state used by a
precedence DFA for a particular precedence value. The transformation
process applies the following changes to the start state's configuration
set.
inherited
-
canDropLoopEntryEdgeInLeftRecursiveRule(ATNConfig config)
→ bool
-
Implements first-edge (loop entry) elimination as an optimization
during closure operations. See antlr/antlr4#1398.
inherited
-
clearDFA()
→ void
-
Clear the DFA cache used by the current instance. Since the DFA cache may
be shared by multiple ATN simulators, this method may affect the
performance (but not accuracy) of other parsers which are being used
concurrently.
inherited
-
closure(ATNConfig config, ATNConfigSet configs, Set<ATNConfig> closureBusy, bool collectPredicates, bool fullCtx, bool treatEofAsEpsilon)
→ void
-
inherited
-
closure_(ATNConfig config, ATNConfigSet configs, Set<ATNConfig> closureBusy, bool collectPredicates, bool fullCtx, int depth, bool treatEofAsEpsilon)
→ void
-
Do the actual work of walking epsilon edges */
inherited
-
closureCheckingStopState(ATNConfig config, ATNConfigSet configs, Set<ATNConfig> closureBusy, bool collectPredicates, bool fullCtx, int depth, bool treatEofAsEpsilon)
→ void
-
inherited
-
computeReachSet(ATNConfigSet closure, int t, bool fullCtx)
→ ATNConfigSet?
-
override
-
computeStartState(ATNState p, RuleContext ctx, bool fullCtx)
→ ATNConfigSet
-
inherited
-
computeTargetState(DFA dfa, DFAState previousD, int t)
→ DFAState?
-
Compute a target state for an edge in the DFA, and attempt to add the
computed state and corresponding edge to the DFA.
override
-
dumpDeadEndConfigs(NoViableAltException nvae)
→ void
-
Used for debugging in adaptivePredict around execATN but I cut
it out for clarity now that alg. works well. We can leave this
"dead" code for a bit.
inherited
-
evalSemanticContext(List<PredPrediction> predPredictions, ParserRuleContext outerContext, bool complete)
→ BitSet
-
Look through a list of predicate/alt pairs, returning alts for the
pairs that win. A
Instance
predicate indicates an alt containing an
unpredicated config which behaves as "always true." If !complete
then we stop at the first predicate that evaluates to true. This
includes pairs with null predicates.
inherited
-
evalSemanticContextOne(SemanticContext pred, ParserRuleContext? parserCallStack, int alt, bool fullCtx)
→ bool
-
Evaluate a semantic context within a specific parser context.
override
-
execATN(DFA dfa, DFAState s0, TokenStream input, int startIndex, ParserRuleContext outerContext)
→ int
-
Performs ATN simulation to compute a predicted alternative based
upon the remaining input, but also updates the DFA cache to avoid
having to traverse the ATN again for the same input sequence.
inherited
-
execATNWithFullContext(DFA dfa, DFAState D, ATNConfigSet s0, TokenStream input, int startIndex, ParserRuleContext outerContext)
→ int
-
inherited
-
getAltThatFinishedDecisionEntryRule(ATNConfigSet configs)
→ int
-
inherited
-
getCachedContext(PredictionContext context)
→ PredictionContext
-
inherited
-
getConflictingAlts(ATNConfigSet configs)
→ BitSet
-
Gets a
BitSet
containing the alternatives in configs
which are part of one or more conflicting alternative subsets.
inherited
-
getConflictingAltsOrUniqueAlt(ATNConfigSet configs)
→ BitSet
-
Sam pointed out a problem with the previous definition, v3, of
ambiguous states. If we have another state associated with conflicting
alternatives, we should keep going. For example, the following grammar
inherited
-
getEpsilonTarget(ATNConfig config, Transition t, bool collectPredicates, bool inContext, bool fullCtx, bool treatEofAsEpsilon)
→ ATNConfig?
-
inherited
-
getExistingTargetState(DFAState previousD, int t)
→ DFAState?
-
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.
override
-
getLookaheadName(TokenStream input)
→ String
-
inherited
-
getPredicatePredictions(BitSet? ambigAlts, List<SemanticContext?> altToPred)
→ List<PredPrediction>?
-
inherited
-
getPredsForAmbigAlts(BitSet ambigAlts, ATNConfigSet configs, int nalts)
→ List<SemanticContext?>?
-
inherited
-
getReachableTarget(Transition trans, int ttype)
→ ATNState?
-
inherited
-
getRuleName(int index)
→ String
-
inherited
-
getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(ATNConfigSet configs, ParserRuleContext outerContext)
→ int
-
This method is used to improve the localization of error messages by
choosing an alternative rather than throwing a
NoViableAltException in particular prediction scenarios where the
{@link #ERROR} state was reached during ATN simulation.
inherited
-
getTokenName(int t)
→ String
-
inherited
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
noViableAlt(TokenStream input, ParserRuleContext outerContext, ATNConfigSet configs, int startIndex)
→ NoViableAltException
-
inherited
-
precedenceTransition(ATNConfig config, PrecedencePredicateTransition pt, bool collectPredicates, bool inContext, bool fullCtx)
→ ATNConfig?
-
inherited
-
predicateDFAState(DFAState dfaState, DecisionState? decisionState)
→ void
-
inherited
-
predTransition(ATNConfig config, PredicateTransition pt, bool collectPredicates, bool inContext, bool fullCtx)
→ ATNConfig?
-
inherited
-
removeAllConfigsNotInRuleStopState(ATNConfigSet configs, bool lookToEndOfRule)
→ ATNConfigSet
-
Return a configuration set containing only the configurations from
configs
which are in a RuleStopState. If all
configurations in configs
are already in a rule stop state, this
method simply returns configs
.
inherited
-
reportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, bool exact, BitSet? ambigAlts, ATNConfigSet configs)
→ void
-
If context sensitive parsing, we know it's ambiguity not conflict */
override
-
reportAttemptingFullContext(DFA dfa, BitSet? conflictingAlts, ATNConfigSet configs, int startIndex, int stopIndex)
→ void
-
override
-
reportContextSensitivity(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex)
→ void
-
override
-
reset()
→ void
-
inherited
-
ruleTransition(ATNConfig config, RuleTransition t)
→ ATNConfig
-
inherited
-
splitAccordingToSemanticValidity(ATNConfigSet configs, ParserRuleContext outerContext)
→ Pair<ATNConfigSet, ATNConfigSet>
-
Walk the list of configurations and split them according to
those that have preds evaluating to true/false. If no pred, assume
true pred and include in succeeded set. Returns Pair of sets.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited