No need to continue SLL prediction if every configuration is at a RuleStopState

This commit is contained in:
Sam Harwell 2013-01-02 09:02:23 -06:00
parent 61b872377c
commit b34ad624bc
1 changed files with 13 additions and 0 deletions

View File

@ -183,6 +183,10 @@ public enum PredictionMode {
predicates.
*/
public static boolean hasSLLConflictTerminatingPrediction(PredictionMode mode, @NotNull ATNConfigSet configs) {
if (onlyRuleStopStates(configs)) {
return true;
}
// pure SLL mode parsing
if ( mode == PredictionMode.SLL ) {
// Don't bother with combining configs from different semantic
@ -208,6 +212,15 @@ public enum PredictionMode {
return heuristic;
}
public static boolean onlyRuleStopStates(@NotNull ATNConfigSet configs) {
for (ATNConfig config : configs) {
if (!(config.state instanceof RuleStopState)) {
return false;
}
}
return true;
}
/**
Full LL prediction termination.