public class DecisionProbe extends Object
Modifier and Type | Field | Description |
---|---|---|
protected Set<Integer> |
altsWithProblem |
The overall list of alts within the decision that have at least one
conflicting input sequence.
|
protected Set<DFAState> |
danglingStates |
The set of states w/o emanating edges and w/o resolving sem preds.
|
DFA |
dfa |
|
boolean |
nonLLStarDecision |
If decision with > 1 alt has recursion in > 1 alt, it's (likely) nonregular
lookahead.
|
static Integer |
REACHABLE_BUSY |
|
static Integer |
REACHABLE_NO |
|
static Integer |
REACHABLE_YES |
|
protected Map<Integer,Integer> |
stateReachable |
Used to find paths through syntactically ambiguous DFA.
|
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.
|
protected Set<String> |
statesVisitedAtInputDepth |
Used while finding a path through an NFA whose edge labels match
an input sequence.
|
protected Set<Integer> |
statesVisitedDuringSampleSequence |
|
protected Set<DFAState> |
statesWithSyntacticallyAmbiguousAltsSet |
Track all DFA states with nondeterministic alternatives.
|
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.
|
protected Map<DFAState,Map<Integer,Set<org.antlr.runtime.Token>>> |
stateToIncompletelyCoveredAltsMap |
Tracks alts insufficiently covered.
|
protected MultiMap<Integer,NFAConfiguration> |
stateToRecursionOverflowConfigurationsMap |
Recursion is limited to a particular depth.
|
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.
|
protected boolean |
timedOut |
Did ANTLR have to terminate early on the analysis of this decision?
|
static boolean |
verbose |
Constructor | Description |
---|---|
DecisionProbe(DFA dfa) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
analysisOverflowed() |
Took too long to analyze a DFA
|
Set<DFAState> |
getDanglingStates() |
return set of states w/o emanating edges and w/o resolving sem preds.
|
String |
getDescription() |
Return a string like "3:22: ( A {;} | B )" that describes this
decision.
|
protected Set<DFAState> |
getDFAPathStatesToTarget(DFAState targetState) |
|
Set<DFAState> |
getDFAStatesWithSyntacticallyAmbiguousAlts() |
Return all DFA states in this DFA that have NFA configurations that
conflict.
|
Set<Integer> |
getDisabledAlternatives(DFAState d) |
Which alts were specifically turned off to resolve nondeterminisms?
This is different than the unreachable alts.
|
Map<Integer,Set<org.antlr.runtime.Token>> |
getIncompletelyCoveredAlts(DFAState d) |
Return a list of alts whose predicate context was insufficient to
resolve a nondeterminism for state d.
|
String |
getInputSequenceDisplay(List<? extends Label> labels) |
Given List<Label>, return a String with a useful representation
of the associated input string.
|
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.
|
List<? extends NFAState> |
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.
|
Set<Integer> |
getNonDeterministicAlts() |
|
List<Integer> |
getNonDeterministicAltsForState(DFAState targetState) |
Return the sorted list of alts that conflict within a single state.
|
Set<DFAState> |
getNondeterministicStatesResolvedWithSemanticPredicate() |
|
int |
getNumberOfStates() |
How many states does the DFA predictor have?
|
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.
|
List<Label> |
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).
|
SemanticContext |
getSemanticContextForAlt(DFAState d,
int alt) |
Each state in the DFA represents a different input sequence for an
alt of the decision.
|
protected String |
getStateLabelIndexKey(int s,
int i) |
|
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.
|
List<Integer> |
getUnreachableAlts() |
Get a list of all unreachable alternatives for this decision.
|
boolean |
hasPredicate() |
At least one alt refs a sem or syn pred
|
boolean |
isCyclic() |
|
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.
|
boolean |
isNonLLStarDecision() |
Found recursion in > 1 alt
|
boolean |
isReduced() |
|
protected void |
issueRecursionWarnings() |
|
void |
issueWarnings() |
|
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.
|
void |
removeRecursiveOverflowState(DFAState d) |
If a recursion overflow is resolve with predicates, then we need
to shut off the warning that would be generated.
|
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.
|
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.
|
void |
reportIncompletelyCoveredAlts(DFAState d,
Map<Integer,Set<org.antlr.runtime.Token>> altToLocationsReachableWithoutPredicate) |
|
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.
|
void |
reportNondeterminism(DFAState d,
Set<Integer> nondeterministicAlts) |
|
void |
reportNondeterminismResolvedWithSemanticPredicate(DFAState d) |
|
void |
reportNonLLStarDecision(DFA dfa) |
Report that at least 2 alts have recursive constructs.
|
void |
reportRecursionOverflow(DFAState d,
NFAConfiguration recursionNFAConfiguration) |
|
void |
reset() |
|
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.
|
public DFA dfa
protected Set<DFAState> statesWithSyntacticallyAmbiguousAltsSet
protected Map<DFAState,Set<Integer>> stateToSyntacticallyAmbiguousTokensRuleAltsMap
protected Set<DFAState> statesResolvedWithSemanticPredicatesSet
protected Map<DFAState,Map<Integer,SemanticContext>> stateToAltSetWithSemanticPredicatesMap
protected Map<DFAState,Map<Integer,Set<org.antlr.runtime.Token>>> stateToIncompletelyCoveredAltsMap
protected Set<DFAState> danglingStates
protected Set<Integer> altsWithProblem
public boolean nonLLStarDecision
protected MultiMap<Integer,NFAConfiguration> stateToRecursionOverflowConfigurationsMap
protected boolean timedOut
protected Map<Integer,Integer> stateReachable
public static final Integer REACHABLE_BUSY
public static final Integer REACHABLE_NO
public static final Integer REACHABLE_YES
protected Set<String> statesVisitedAtInputDepth
public static boolean verbose
public DecisionProbe(DFA dfa)
public String getDescription()
public boolean isReduced()
public boolean isCyclic()
public boolean isDeterministic()
public boolean analysisOverflowed()
public boolean isNonLLStarDecision()
public int getNumberOfStates()
public List<Integer> getUnreachableAlts()
public Set<DFAState> getDanglingStates()
public List<Integer> getNonDeterministicAltsForState(DFAState targetState)
public Set<DFAState> getDFAStatesWithSyntacticallyAmbiguousAlts()
public Set<Integer> getDisabledAlternatives(DFAState d)
public void removeRecursiveOverflowState(DFAState d)
public List<Label> getSampleNonDeterministicInputSequence(DFAState targetState)
public String getInputSequenceDisplay(List<? extends Label> labels)
public List<? extends NFAState> getNFAPathStatesForAlt(int firstAlt, int alt, List<? extends Label> labels)
public SemanticContext getSemanticContextForAlt(DFAState d, int alt)
public boolean hasPredicate()
public Set<DFAState> getNondeterministicStatesResolvedWithSemanticPredicate()
public Map<Integer,Set<org.antlr.runtime.Token>> getIncompletelyCoveredAlts(DFAState d)
public void issueWarnings()
protected void stripWildCardAlts(Set<Integer> disabledAlts)
protected void issueRecursionWarnings()
public void reportDanglingState(DFAState d)
public void reportNonLLStarDecision(DFA dfa)
public void reportRecursionOverflow(DFAState d, NFAConfiguration recursionNFAConfiguration)
public void reportNondeterminism(DFAState d, Set<Integer> nondeterministicAlts)
public void reportLexerRuleNondeterminism(DFAState d, Set<Integer> nondeterministicAlts)
public void reportNondeterminismResolvedWithSemanticPredicate(DFAState d)
public void reportAltPredicateContext(DFAState d, Map<Integer,? extends SemanticContext> altPredicateContext)
public void reportIncompletelyCoveredAlts(DFAState d, Map<Integer,Set<org.antlr.runtime.Token>> altToLocationsReachableWithoutPredicate)
protected boolean reachesState(DFAState startState, DFAState targetState, Set<DFAState> states)
protected void getSampleInputSequenceUsingStateSet(State startState, State targetState, Set<DFAState> states, List<Label> labels)
protected boolean getNFAPath(NFAState s, int labelIndex, List<? extends Label> labels, List<? super NFAState> path)
protected String getStateLabelIndexKey(int s, int i)
public String getTokenNameForTokensRuleAlt(int alt)
public void reset()
Copyright © 1992–2019 ANTLR. All rights reserved.