diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java index 354e4a4ad..bbc07eec8 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java @@ -36,8 +36,10 @@ import org.antlr.v4.runtime.misc.Nullable; import org.antlr.v4.runtime.misc.ObjectEqualityComparator; public class LexerATNConfig extends ATNConfig { - /** Capture lexer actions we traverse. */ - public LexerActionExecutor lexerActionExecutor; + /** + * This is the backing field for {@link #getLexerActionExecutor}. + */ + private final LexerActionExecutor lexerActionExecutor; private final boolean passedThroughNonGreedyDecision; @@ -47,6 +49,7 @@ public class LexerATNConfig extends ATNConfig { { super(state, alt, context, SemanticContext.NONE); this.passedThroughNonGreedyDecision = false; + this.lexerActionExecutor = null; } public LexerATNConfig(@NotNull ATNState state, @@ -80,6 +83,14 @@ public class LexerATNConfig extends ATNConfig { this.passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state); } + /** + * Gets the {@link LexerActionExecutor} capable of executing the embedded + * action(s) for the current configuration. + */ + public final LexerActionExecutor getLexerActionExecutor() { + return lexerActionExecutor; + } + public final boolean hasPassedThroughNonGreedyDecision() { return passedThroughNonGreedyDecision; } 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 7a9defa9f..2849fa3b3 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java @@ -346,7 +346,7 @@ public class LexerATNSimulator extends ATNSimulator { Transition trans = c.state.transition(ti); ATNState target = getReachableTarget(trans, t); if ( target!=null ) { - LexerActionExecutor lexerActionExecutor = ((LexerATNConfig)c).lexerActionExecutor; + LexerActionExecutor lexerActionExecutor = ((LexerATNConfig)c).getLexerActionExecutor(); if (lexerActionExecutor != null) { lexerActionExecutor = lexerActionExecutor.fixOffsetBeforeMatch(input.index() - startIndex); } @@ -537,7 +537,7 @@ public class LexerATNSimulator extends ATNSimulator { // getEpsilonTarget to return two configurations, so // additional modifications are needed before we can support // the split operation. - LexerActionExecutor lexerActionExecutor = LexerActionExecutor.append(config.lexerActionExecutor, atn.lexerActions[((ActionTransition)t).actionIndex]); + LexerActionExecutor lexerActionExecutor = LexerActionExecutor.append(config.getLexerActionExecutor(), atn.lexerActions[((ActionTransition)t).actionIndex]); c = new LexerATNConfig(config, t.target, lexerActionExecutor); break; } @@ -684,7 +684,7 @@ public class LexerATNSimulator extends ATNSimulator { if ( firstConfigWithRuleStopState!=null ) { proposed.isAcceptState = true; - proposed.lexerActionExecutor = ((LexerATNConfig)firstConfigWithRuleStopState).lexerActionExecutor; + proposed.lexerActionExecutor = ((LexerATNConfig)firstConfigWithRuleStopState).getLexerActionExecutor(); proposed.prediction = atn.ruleToTokenType[firstConfigWithRuleStopState.state.ruleIndex]; }