a few tweaks/comments.

This commit is contained in:
Terence Parr 2012-10-20 12:51:36 -07:00
parent d996b5c8c7
commit ab6b341942
3 changed files with 11 additions and 3 deletions

View File

@ -75,6 +75,14 @@ public class ATNConfig {
return true;
}
/** Lexer non-greedy implementations need to track information per
* ATNConfig. When the lexer reaches an accept state for a lexer
* rule, it needs to wipe out any configurations associated with
* that rule that are part of a non-greedy subrule. To do that it
* has to make sure that it tracks when a configuration was derived
* from an element within a non-greedy subrule. We use depth for
* that. We're greedy when the depth is 0.
*/
public int getNonGreedyDepth() {
return 0;
}

View File

@ -444,7 +444,7 @@ public class LexerATNSimulator extends ATNSimulator {
}
}
if (!((LexerATNConfig)config).isGreedy()) {
if ( !config.isGreedy() ) {
assert !(config.state instanceof RuleStopState);
nonGreedyAlts.set(config.alt);
}
@ -582,7 +582,7 @@ public class LexerATNSimulator extends ATNSimulator {
}
}
if ( config.context == null || config.context.hasEmpty() ) {
if ( config.context == null || config.context.hasEmptyPath() ) {
if (config.context == null || config.context.isEmpty()) {
configs.add(config);
return;

View File

@ -70,7 +70,7 @@ public abstract class PredictionContext implements Iterable<SingletonPredictionC
return this == EMPTY;
}
public boolean hasEmpty() {
public boolean hasEmptyPath() {
return getInvokingState(size() - 1) == EMPTY_INVOKING_STATE;
}