diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java index adfe2b3d5..449eacc4c 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java @@ -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; } diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java index 9ba0dc1a8..0c659afac 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java @@ -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; diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java index 73712e5fc..f5ad3f0f7 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java @@ -70,7 +70,7 @@ public abstract class PredictionContext implements Iterable