Class ReachComputation
Owns the retained reach and intermediate ATNConfigSets plus the
ReachConfigSource view used by a single
ParserATNSimulator.computeTargetState(org.antlr.v4.runtime.dfa.DFA, org.antlr.v4.runtime.dfa.DFAState, org.antlr.v4.runtime.ParserRuleContext, int, boolean, org.antlr.v4.runtime.atn.PredictionContextCache) invocation. Extracted so
ParserATNSimulator stays focused on adaptivePredict / DFA
orchestration while allocation and release policy for edge computation live
in one place.
Ownership: one instance per ParserATNSimulator. A
simulator is used by one parser thread at a time during prediction, so
retained scratch is not shared across threads. Each
computeTargetState(org.antlr.v4.runtime.dfa.DFA, org.antlr.v4.runtime.dfa.DFAState, org.antlr.v4.runtime.ParserRuleContext, int, boolean, org.antlr.v4.runtime.atn.PredictionContextCache) binds scratch inside try/finally
and always releases after the edge is
cloned into the DFA.
Not part of any public or protected API.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RetainedConfigSetprivate final RetainedConfigSetRetained reach / intermediate sets.private final ReachConfigSourceRetained config view.private final ParserATNSimulator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Tuple2<DFAState,ParserRuleContext> computeTargetState(DFA dfa, DFAState s, ParserRuleContext remainingGlobalContext, int t, boolean useContext, PredictionContextCache contextCache) Compute a target state for an edge in the DFA, and attempt to add the computed state and corresponding edge to the DFA.private Tuple2<DFAState,ParserRuleContext> finishTargetEdge(DFA dfa, DFAState s, int t, IntegerList contextElements, ATNConfigSet edgeConfigs, ParserRuleContext remainingGlobalContext, PredictionContextCache contextCache) Install a DFA edge for the computed config set, orATNSimulator.ERRORif empty.(package private) ReachConfigSourceRetained config source after construction.
-
Field Details
-
simulator
-
retainedReach
Retained reach / intermediate sets.RetainedConfigSet.obtain(int)always returns empty;RetainedConfigSet.release()runs infinallyafter each edge. -
retainedIntermediate
-
retainedReachConfigs
Retained config view.ReachConfigSource.reset(org.antlr.v4.runtime.atn.ATNConfigSet)binds the source set;ReachConfigSource.release()runs infinallyso the full-context rewrite list keeps capacity across predictions.
-
-
Constructor Details
-
ReachComputation
ReachComputation(@NotNull ParserATNSimulator simulator)
-
-
Method Details
-
retainedReachConfigs
Retained config source after construction. Same-package tests may observe rewrite-list identity across full-context edges. -
computeTargetState
@NotNull Tuple2<DFAState,ParserRuleContext> computeTargetState(@NotNull DFA dfa, @NotNull DFAState s, ParserRuleContext remainingGlobalContext, int t, boolean useContext, PredictionContextCache contextCache) Compute a target state for an edge in the DFA, and attempt to add the computed state and corresponding edge to the DFA.- Returns:
- The computed target DFA state for the given input symbol
t. Iftdoes not lead to a valid DFA state, this method returnsATNSimulator.ERROR.
-
finishTargetEdge
@NotNull private Tuple2<DFAState,ParserRuleContext> finishTargetEdge(@NotNull DFA dfa, @NotNull DFAState s, int t, @Nullable IntegerList contextElements, @NotNull ATNConfigSet edgeConfigs, ParserRuleContext remainingGlobalContext, PredictionContextCache contextCache) Install a DFA edge for the computed config set, orATNSimulator.ERRORif empty.
-