- parser
Parser parser;
Undocumented in source.
- decisionToDFA
DFA[] decisionToDFA;
Undocumented in source.
- mode
PredictionModeConst mode;
Undocumented in source.
- mergeCache
DoubleKeyMap!(PredictionContext, PredictionContext, PredictionContext) mergeCache;
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.
@uml
@__gshared
- _dfa
DFA _dfa;
Undocumented in source.
- _input
TokenStream _input;
Undocumented in source.
- _startIndex
int _startIndex;
Undocumented in source.
- _outerContext
ParserRuleContext _outerContext;
Undocumented in source.
- reset
void reset()
- clearDFA
void clearDFA()
- adaptivePredict
int adaptivePredict(TokenStream input, int decision, ParserRuleContext outerContext)
Undocumented in source. Be warned that the author may not have intended to support it.
- execATN
int execATN(DFA dfa, DFAState s0, TokenStream input, int startIndex, ParserRuleContext outerContext)
There are some key conditions we're looking for after computing a new
set of ATN configs (proposed DFA state):
* if the set is empty, there is no viable alternative for current symbol
* does the state uniquely predict an alternative?
* does the state have a conflict that would prevent us from
putting it on the work list?
- getExistingTargetState
DFAState getExistingTargetState(DFAState previousD, int t)
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 {@code null}.
- computeTargetState
DFAState computeTargetState(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.
- predicateDFAState
void predicateDFAState(DFAState dfaState, DecisionState decisionState)
Undocumented in source. Be warned that the author may not have intended to support it.
- execATNWithFullContext
int execATNWithFullContext(DFA dfa, DFAState D, ATNConfigSet s0, TokenStream input, int startIndex, ParserRuleContext outerContext)
@uml
comes back with reach.uniqueAlt set to a valid alt
- computeReachSet
ATNConfigSet computeReachSet(ATNConfigSet closure, int t, bool fullCtx)
Undocumented in source. Be warned that the author may not have intended to support it.
- removeAllConfigsNotInRuleStopState
ATNConfigSet removeAllConfigsNotInRuleStopState(ATNConfigSet configs, bool lookToEndOfRule)
Return a configuration set containing only the configurations from
{@code configs} which are in a {@link RuleStopState}. If all
configurations in {@code configs} are already in a rule stop state, this
method simply returns {@code configs}.
- computeStartState
ATNConfigSet computeStartState(ATNState p, RuleContext ctx, bool fullCtx)
Undocumented in source. Be warned that the author may not have intended to support it.
- applyPrecedenceFilter
ATNConfigSet applyPrecedenceFilter(ATNConfigSet configs)
Undocumented in source. Be warned that the author may not have intended to support it.
- getReachableTarget
ATNState getReachableTarget(Transition trans, int ttype)
Undocumented in source. Be warned that the author may not have intended to support it.
- getPredsForAmbigAlts
SemanticContext[] getPredsForAmbigAlts(BitSet ambigAlts, ATNConfigSet configs, int nalts)
Undocumented in source. Be warned that the author may not have intended to support it.
- getPredicatePredictions
PredPrediction[] getPredicatePredictions(BitSet ambigAlts, SemanticContext[] altToPred)
Undocumented in source. Be warned that the author may not have intended to support it.
- getAltThatFinishedDecisionEntryRule
int getAltThatFinishedDecisionEntryRule(ATNConfigSet configs)
Undocumented in source. Be warned that the author may not have intended to support it.
- getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule
int getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(ATNConfigSet configs, ParserRuleContext outerContext)
This method is used to improve the localization of error messages by
choosing an alternative rather than throwing a
{@link NoViableAltException} in particular prediction scenarios where the
{@link #ERROR} state was reached during ATN simulation.
- splitAccordingToSemanticValidity
ATNConfigSetATNConfigSetPair splitAccordingToSemanticValidity(ATNConfigSet configs, ParserRuleContext outerContext)
Undocumented in source. Be warned that the author may not have intended to support it.
- evalSemanticContext
BitSet evalSemanticContext(PredPrediction[] predPredictions, ParserRuleContext outerContext, bool complete)
pairs that win. A {@code NONE} 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.
- evalSemanticContext
bool evalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt, bool fullCtx)
Undocumented in source. Be warned that the author may not have intended to support it.
- closureATN
void closureATN(ATNConfig config, ATNConfigSet configs, ATNConfig[] closureBusy, bool collectPredicates, bool fullCtx, bool treatEofAsEpsilon)
Undocumented in source. Be warned that the author may not have intended to support it.
- closureCheckingStopState
void closureCheckingStopState(ATNConfig config, ATNConfigSet configs, ATNConfig[] closureBusy, bool collectPredicates, bool fullCtx, int depth, bool treatEofAsEpsilon)
Undocumented in source. Be warned that the author may not have intended to support it.
- closure_
void closure_(ATNConfig config, ATNConfigSet configs, ATNConfig[] closureBusy, bool collectPredicates, bool fullCtx, int depth, bool treatEofAsEpsilon)
Do the actual work of walking epsilon edges
- getRuleName
string getRuleName(int index)
Undocumented in source. Be warned that the author may not have intended to support it.
- getEpsilonTarget
ATNConfig getEpsilonTarget(ATNConfig config, Transition t, bool collectPredicates, bool inContext, bool fullCtx, bool treatEofAsEpsilon)
Undocumented in source. Be warned that the author may not have intended to support it.
- actionTransition
ATNConfig actionTransition(ATNConfig config, ActionTransition t)
Undocumented in source. Be warned that the author may not have intended to support it.
- precedenceTransition
ATNConfig precedenceTransition(ATNConfig config, PrecedencePredicateTransition pt, bool collectPredicates, bool inContext, bool fullCtx)
Undocumented in source. Be warned that the author may not have intended to support it.
- predTransition
ATNConfig predTransition(ATNConfig config, PredicateTransition pt, bool collectPredicates, bool inContext, bool fullCtx)
Undocumented in source. Be warned that the author may not have intended to support it.
- ruleTransition
ATNConfig ruleTransition(ATNConfig config, RuleTransition t)
Undocumented in source. Be warned that the author may not have intended to support it.
- getConflictingAlts
BitSet getConflictingAlts(ATNConfigSet configs)
Gets a {@link BitSet} containing the alternatives in {@code configs}
which are part of one or more conflicting alternative subsets.
- getConflictingAltsOrUniqueAlt
BitSet getConflictingAltsOrUniqueAlt(ATNConfigSet configs)
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
- getTokenName
string getTokenName(int t)
Undocumented in source. Be warned that the author may not have intended to support it.
- getLookaheadName
string getLookaheadName(TokenStream input)
Undocumented in source. Be warned that the author may not have intended to support it.
- dumpDeadEndConfigs
void dumpDeadEndConfigs(NoViableAltException nvae)
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.
- noViableAlt
NoViableAltException noViableAlt(TokenStream input, ParserRuleContext outerContext, ATNConfigSet configs, int startIndex)
Undocumented in source. Be warned that the author may not have intended to support it.
- getUniqueAlt
int getUniqueAlt(ATNConfigSet configs)
Undocumented in source. Be warned that the author may not have intended to support it.
- addDFAEdge
DFAState addDFAEdge(DFA dfa, DFAState from, int t, DFAState to)
Add an edge to the DFA, if possible. This method calls
{@link #addDFAState} to ensure the {@code to} state is present in the
DFA. If {@code from} is {@code null}, or if {@code 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.
- addDFAState
DFAState addDFAState(DFA dfa, DFAState D)
Add state {@code D} to the DFA if it is not already present, and return
the actual instance stored in the DFA. If a state equivalent to {@code D}
is already in the DFA, the existing state is returned. Otherwise this
method returns {@code D} after adding it to the DFA.
- reportAttemptingFullContext
void reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, ATNConfigSet configs, int startIndex, int stopIndex)
Undocumented in source. Be warned that the author may not have intended to support it.
- reportContextSensitivity
void reportContextSensitivity(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex)
Undocumented in source. Be warned that the author may not have intended to support it.
- reportAmbiguity
void reportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs)
Undocumented in source. Be warned that the author may not have intended to support it.
- setPredictionMode
void setPredictionMode(PredictionModeConst mode)
Undocumented in source. Be warned that the author may not have intended to support it.
- getPredictionMode
PredictionModeConst getPredictionMode()
Undocumented in source. Be warned that the author may not have intended to support it.
- getParser
Parser getParser()
Undocumented in source. Be warned that the author may not have intended to support it.
- canDropLoopEntryEdgeInLeftRecursiveRule
bool canDropLoopEntryEdgeInLeftRecursiveRule(ATNConfig config)
Undocumented in source. Be warned that the author may not have intended to support it.
TODO add class description