| Modifier and Type | Field and Description |
|---|---|
| protected Set | altsWithProblem
The overall list of alts within the decision that have at least one conflicting input sequence. |
| protected Set | danglingStates
The set of states w/o emanating edges and w/o resolving sem preds. |
| public DFA | |
| public boolean | nonLLStarDecision
If decision with > 1 alt has recursion in > 1 alt, it's (likely) nonregular lookahead. |
| public static final Integer | |
| public static final Integer | |
| public static final Integer | |
| protected Map | stateReachable
Used to find paths through syntactically ambiguous DFA. |
| protected Set | statesResolvedWithSemanticPredicatesSet
Was a syntactic ambiguity resolved with predicates? |
| protected Set | statesVisitedAtInputDepth
Used while finding a path through an NFA whose edge labels match an input sequence. |
| protected Set | |
| protected Set | statesWithSyntacticallyAmbiguousAltsSet
Track all DFA states with nondeterministic alternatives. |
| protected Map | stateToAltSetWithSemanticPredicatesMap
Track the predicates for each alt per DFA state; more than one DFA state might have syntactically ambig alt prediction. |
| protected Map | stateToIncompletelyCoveredAltsMap
Tracks alts insufficiently covered. |
| protected MultiMap | stateToRecursionOverflowConfigurationsMap
Recursion is limited to a particular depth. |
| protected Map | stateToSyntacticallyAmbiguousTokensRuleAltsMap
Track just like stateToSyntacticallyAmbiguousAltsMap, but only for nondeterminisms that arise in the Tokens rule such as keyword vs ID rule. |
| protected boolean | timedOut
Did ANTLR have to terminate early on the analysis of this decision? |
| public static boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| private void | |
| public Set | |
| public String | |
| protected Set | |
| public Set | getDFAStatesWithSyntacticallyAmbiguousAlts()
Return all DFA states in this DFA that have NFA configurations that conflict. |
| public Set | getDisabledAlternatives(DFAState d)
Which alts were specifically turned off to resolve nondeterminisms? |
| public Map | getIncompletelyCoveredAlts(DFAState d)
Return a list of alts whose predicate context was insufficient to resolve a nondeterminism for state d. |
| public String | getInputSequenceDisplay(List<? extends Label> labels)
Given List<Label>, return a String with a useful representation of the associated input string. |
| protected boolean | |
| public List | getNFAPathStatesForAlt(int firstAlt, int alt, List<? extends Label> labels)
Given an alternative associated with a nondeterministic DFA state, find the path of NFA states associated with the labels sequence. |
| public Set | |
| public List | getNonDeterministicAltsForState(DFAState targetState)
Return the sorted list of alts that conflict within a single state. |
| public Set | |
| public int | |
| protected void | |
| public List | getSampleNonDeterministicInputSequence(DFAState targetState)
Return a List<Label> indicating an input sequence that can be matched from the start state of the DFA to the targetState (which is known to have a problem). |
| public SemanticContext | getSemanticContextForAlt(DFAState d, int alt)
Each state in the DFA represents a different input sequence for an alt of the decision. |
| protected String | |
| public String | getTokenNameForTokensRuleAlt(int alt)
From an alt number associated with artificial Tokens rule, return the name of the token that is associated with that alt. |
| private Set | |
| public List | |
| public boolean | |
| public boolean | |
| public boolean | isDeterministic()
If no states are dead-ends, no alts are unreachable, there are no nondeterminisms unresolved by syn preds, all is ok with decision. |
| public boolean | |
| public boolean | |
| protected void | |
| public void | |
| protected boolean | reachesState(DFAState startState, DFAState targetState, Set<DFAState> states)
Given a start state and a target state, return true if start can reach target state. |
| public void | removeRecursiveOverflowState(DFAState d)
If a recursion overflow is resolve with predicates, then we need to shut off the warning that would be generated. |
| public void | reportAltPredicateContext(DFAState d, Map<Integer, ? extends SemanticContext> altPredicateContext)
Report the list of predicates found for each alternative; copy the list because this set gets altered later by the method tryToResolveWithSemanticPredicates() while flagging NFA configurations in d as resolved. |
| public void | reportDanglingState(DFAState d)
Report the fact that DFA state d is not a state resolved with predicates and yet it has no emanating edges. |
| public void | |
| public void | reportLexerRuleNondeterminism(DFAState d, Set<Integer> nondeterministicAlts)
Currently the analysis reports issues between token definitions, but we don't print out warnings in favor of just picking the first token definition found in the grammar ala lex/flex. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| protected void | stripWildCardAlts(Set<Integer> disabledAlts)
Get the last disabled alt number and check in the grammar to see if that alt is a simple wildcard. |
| altsWithProblem | back to summary |
|---|---|
| protected Set<Integer> altsWithProblem The overall list of alts within the decision that have at least one conflicting input sequence. | |
| danglingStates | back to summary |
|---|---|
| protected Set<DFAState> danglingStates The set of states w/o emanating edges and w/o resolving sem preds. | |
| dfa | back to summary |
|---|---|
| public DFA dfa | |
| nonLLStarDecision | back to summary |
|---|---|
| public boolean nonLLStarDecision If decision with > 1 alt has recursion in > 1 alt, it's (likely) nonregular lookahead. The decision cannot be made with a DFA. the alts are stored in altsWithProblem. | |
| REACHABLE_BUSY | back to summary |
|---|---|
| public static final Integer REACHABLE_BUSY | |
| REACHABLE_NO | back to summary |
|---|---|
| public static final Integer REACHABLE_NO | |
| REACHABLE_YES | back to summary |
|---|---|
| public static final Integer REACHABLE_YES | |
| stateReachable | back to summary |
|---|---|
| protected Map<Integer, Integer> stateReachable Used to find paths through syntactically ambiguous DFA. If we've seen statement number before, what did we learn? | |
| statesResolvedWithSemanticPredicatesSet | back to summary |
|---|---|
| protected Set<DFAState> statesResolvedWithSemanticPredicatesSet Was a syntactic ambiguity resolved with predicates? Any DFA state that predicts more than one alternative, must be resolved with predicates or it should be reported to the user. | |
| statesVisitedAtInputDepth | back to summary |
|---|---|
| protected Set<String> statesVisitedAtInputDepth Used while finding a path through an NFA whose edge labels match an input sequence. Tracks the input position we were at the last time at this node. If same input position, then we'd have reached same state without consuming input...probably an infinite loop. Stop. Set<String>. The strings look like stateNumber_labelIndex. | |
| statesVisitedDuringSampleSequence | back to summary |
|---|---|
| protected Set<Integer> statesVisitedDuringSampleSequence | |
| statesWithSyntacticallyAmbiguousAltsSet | back to summary |
|---|---|
| protected Set<DFAState> statesWithSyntacticallyAmbiguousAltsSet Track all DFA states with nondeterministic alternatives. By reaching the same DFA state, a path through the NFA for some input is able to reach the same NFA state by starting at more than one alternative's left edge. Though, later, we may find that predicates resolve the issue, but track info anyway. Note that from the DFA state, you can ask for which alts are nondeterministic. | |
| stateToAltSetWithSemanticPredicatesMap | back to summary |
|---|---|
| protected Map<DFAState, Map<Integer, SemanticContext>> stateToAltSetWithSemanticPredicatesMap Track the predicates for each alt per DFA state; more than one DFA state might have syntactically ambig alt prediction. Maps DFA state to another map, mapping alt number to a SemanticContext (pred(s) to execute to resolve syntactic ambiguity). | |
| stateToIncompletelyCoveredAltsMap | back to summary |
|---|---|
| protected Map<DFAState, Map<Integer, Set<Token>>> stateToIncompletelyCoveredAltsMap Tracks alts insufficiently covered. For example, p1||true gets reduced to true and so leaves whole alt uncovered. This maps DFA state to the set of alts | |
| stateToRecursionOverflowConfigurationsMap | back to summary |
|---|---|
| protected MultiMap<Integer, NFAConfiguration> stateToRecursionOverflowConfigurationsMap Recursion is limited to a particular depth. If that limit is exceeded the proposed new NFAConfiguration is recorded for the associated DFA state. | |
| stateToSyntacticallyAmbiguousTokensRuleAltsMap | back to summary |
|---|---|
| protected Map<DFAState, Set<Integer>> stateToSyntacticallyAmbiguousTokensRuleAltsMap Track just like stateToSyntacticallyAmbiguousAltsMap, but only for nondeterminisms that arise in the Tokens rule such as keyword vs ID rule. The state maps to the list of Tokens rule alts that are in conflict. | |
| timedOut | back to summary |
|---|---|
| protected boolean timedOut Did ANTLR have to terminate early on the analysis of this decision? | |
| verbose | back to summary |
|---|---|
| public static boolean verbose | |
| DecisionProbe | back to summary |
|---|---|
| public DecisionProbe(DFA dfa) | |
| analysisOverflowed | back to summary |
|---|---|
| public boolean analysisOverflowed() Took too long to analyze a DFA | |
| computeAltToProblemMaps | back to summary |
|---|---|
| private void computeAltToProblemMaps(Set<Integer> dfaStatesUnaliased, Map<Integer, List<NFAConfiguration>> configurationsMap, Map<Integer, Map<String, Set<NFAState>>> altToTargetToCallSitesMap, Map<Integer, DFAState> altToDFAState) | |
| getDanglingStates | back to summary |
|---|---|
| public Set return set of states w/o emanating edges and w/o resolving sem preds. These states come about because the analysis algorithm had to terminate early to avoid infinite recursion for example (due to left recursion perhaps). | |
| getDescription | back to summary |
|---|---|
| public String getDescription() Return a string like "3:22: ( A {;} | B )" that describes this decision. | |
| getDFAPathStatesToTarget | back to summary |
|---|---|
| protected Set | |
| getDFAStatesWithSyntacticallyAmbiguousAlts | back to summary |
|---|---|
| public Set Return all DFA states in this DFA that have NFA configurations that conflict. You must report a problem for each state in this set because each state represents a different input sequence. | |
| getDisabledAlternatives | back to summary |
|---|---|
| public Set Which alts were specifically turned off to resolve nondeterminisms? This is different than the unreachable alts. Disabled doesn't mean that the alternative is totally unreachable necessarily, it just means that for this DFA state, that alt is disabled. There may be other accept states for that alt that make an alt reachable. | |
| getIncompletelyCoveredAlts | back to summary |
|---|---|
| public Map Return a list of alts whose predicate context was insufficient to resolve a nondeterminism for state d. | |
| getInputSequenceDisplay | back to summary |
|---|---|
| public String getInputSequenceDisplay(List<? extends Label> labels) Given List<Label>, return a String with a useful representation of the associated input string. One could show something different for lexers and parsers, for example. | |
| getNFAPath | back to summary |
|---|---|
| protected boolean getNFAPath(NFAState s, int labelIndex, List<? extends Label> labels, List<? super NFAState> path) Given a sample input sequence, you usually would like to know the path taken through the NFA. Return the list of NFA states visited while matching a list of labels. This cannot use the usual interpreter, which does a deterministic walk. We need to be able to take paths that are turned off during nondeterminism resolution. So, just do a depth-first walk traversing edges labeled with the current label. Return true if a path was found emanating from state s. | |
| getNFAPathStatesForAlt | back to summary |
|---|---|
| public List Given an alternative associated with a nondeterministic DFA state, find the path of NFA states associated with the labels sequence. Useful tracing where in the NFA, a single input sequence can be matched. For different alts, you should get different NFA paths. The first NFA state for all NFA paths will be the same: the starting NFA state of the first nondeterministic alt. Imagine (A|B|A|A): 5->9-A->o | 6->10-B->o | 7->11-A->o | 8->12-A->o There are 3 nondeterministic alts. The paths should be: 5 9 ... 5 6 7 11 ... 5 6 7 8 12 ... The NFA path matching the sample input sequence (labels) is computed using states 9, 11, and 12 rather than 5, 7, 8 because state 5, for example can get to all ambig paths. Must isolate for each alt (hence, the extra state beginning each alt in my NFA structures). Here, firstAlt=1. | |
| getNonDeterministicAlts | back to summary |
|---|---|
| public Set | |
| getNonDeterministicAltsForState | back to summary |
|---|---|
| public List Return the sorted list of alts that conflict within a single state. Note that predicates may resolve the conflict. | |
| getNondeterministicStatesResolvedWithSemanticPredicate | back to summary |
|---|---|
| public Set | |
| getNumberOfStates | back to summary |
|---|---|
| public int getNumberOfStates() How many states does the DFA predictor have? | |
| getSampleInputSequenceUsingStateSet | back to summary |
|---|---|
| protected void getSampleInputSequenceUsingStateSet(State startState, State targetState, Set<DFAState> states, List<Label> labels) Given a start state and a final state, find a list of edge labels between the two ignoring epsilon. Limit your scan to a set of states passed in. This is used to show a sample input sequence that is nondeterministic with respect to this decision. Return List<Label> as a parameter. The incoming states set must be all states that lead from startState to targetState and no others so this algorithm doesn't take a path that eventually leads to a state other than targetState. Don't follow loops, leading to short (possibly shortest) path. | |
| getSampleNonDeterministicInputSequence | back to summary |
|---|---|
| public List Return a List<Label> indicating an input sequence that can be matched from the start state of the DFA to the targetState (which is known to have a problem). | |
| getSemanticContextForAlt | back to summary |
|---|---|
| public SemanticContext getSemanticContextForAlt(DFAState d, int alt) Each state in the DFA represents a different input sequence for an alt of the decision. Given a DFA state, what is the semantic predicate context for a particular alt. | |
| getStateLabelIndexKey | back to summary |
|---|---|
| protected String getStateLabelIndexKey(int s, int i) | |
| getTokenNameForTokensRuleAlt | back to summary |
|---|---|
| public String getTokenNameForTokensRuleAlt(int alt) From an alt number associated with artificial Tokens rule, return the name of the token that is associated with that alt. | |
| getUnaliasedDFAStateSet | back to summary |
|---|---|
| private Set | |
| getUnreachableAlts | back to summary |
|---|---|
| public List Get a list of all unreachable alternatives for this decision. There may be multiple alternatives with ambiguous input sequences, but this is the overall list of unreachable alternatives (either due to conflict resolution or alts w/o accept states). | |
| hasPredicate | back to summary |
|---|---|
| public boolean hasPredicate() At least one alt refs a sem or syn pred | |
| isCyclic | back to summary |
|---|---|
| public boolean isCyclic() | |
| isDeterministic | back to summary |
|---|---|
| public boolean isDeterministic() If no states are dead-ends, no alts are unreachable, there are no nondeterminisms unresolved by syn preds, all is ok with decision. | |
| isNonLLStarDecision | back to summary |
|---|---|
| public boolean isNonLLStarDecision() Found recursion in > 1 alt | |
| isReduced | back to summary |
|---|---|
| public boolean isReduced() | |
| issueRecursionWarnings | back to summary |
|---|---|
| protected void issueRecursionWarnings() | |
| issueWarnings | back to summary |
|---|---|
| public void issueWarnings() | |
| reachesState | back to summary |
|---|---|
| protected boolean reachesState(DFAState startState, DFAState targetState, Set<DFAState> states) Given a start state and a target state, return true if start can reach target state. Also, compute the set of DFA states that are on a path from start to target; return in states parameter. | |
| removeRecursiveOverflowState | back to summary |
|---|---|
| public void removeRecursiveOverflowState(DFAState d) If a recursion overflow is resolve with predicates, then we need to shut off the warning that would be generated. | |
| reportAltPredicateContext | back to summary |
|---|---|
| public void reportAltPredicateContext(DFAState d, Map<Integer, ? extends SemanticContext> altPredicateContext) Report the list of predicates found for each alternative; copy the list because this set gets altered later by the method tryToResolveWithSemanticPredicates() while flagging NFA configurations in d as resolved. | |
| reportDanglingState | back to summary |
|---|---|
| public void reportDanglingState(DFAState d) Report the fact that DFA state d is not a state resolved with predicates and yet it has no emanating edges. Usually this is a result of the closure/reach operations being unable to proceed | |
| reportIncompletelyCoveredAlts | back to summary |
|---|---|
| public void reportIncompletelyCoveredAlts(DFAState d, Map<Integer, Set<Token>> altToLocationsReachableWithoutPredicate) | |
| reportLexerRuleNondeterminism | back to summary |
|---|---|
| public void reportLexerRuleNondeterminism(DFAState d, Set<Integer> nondeterministicAlts) Currently the analysis reports issues between token definitions, but we don't print out warnings in favor of just picking the first token definition found in the grammar ala lex/flex. | |
| reportNondeterminism | back to summary |
|---|---|
| public void reportNondeterminism(DFAState d, Set<Integer> nondeterministicAlts) | |
| reportNondeterminismResolvedWithSemanticPredicate | back to summary |
|---|---|
| public void reportNondeterminismResolvedWithSemanticPredicate(DFAState d) | |
| reportNonLLStarDecision | back to summary |
|---|---|
| public void reportNonLLStarDecision(DFA dfa) Report that at least 2 alts have recursive constructs. There is no way to build a DFA so we terminated. | |
| reportRecursionOverflow | back to summary |
|---|---|
| public void reportRecursionOverflow(DFAState d, NFAConfiguration recursionNFAConfiguration) | |
| reset | back to summary |
|---|---|
| public void reset() | |
| stripWildCardAlts | back to summary |
|---|---|
| protected void stripWildCardAlts(Set<Integer> disabledAlts) Get the last disabled alt number and check in the grammar to see if that alt is a simple wildcard. If so, treat like an else clause and don't emit the error. Strip out the last alt if it's wildcard. | |