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 4c0e225de..684eedae2 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfig.java @@ -68,9 +68,6 @@ public class ATNConfig { */ public int reachesIntoOuterContext; - /** Capture lexer action we traverse */ - public int lexerActionIndex = -1; // TOOD: move to subclass - @NotNull public final SemanticContext semanticContext; @@ -112,7 +109,6 @@ public class ATNConfig { this.context = context; this.semanticContext = semanticContext; this.reachesIntoOuterContext = c.reachesIntoOuterContext; - this.lexerActionIndex = c.lexerActionIndex; } /** An ATN configuration is equal to another if both have diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java new file mode 100644 index 000000000..1019eb350 --- /dev/null +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNConfig.java @@ -0,0 +1,41 @@ +package org.antlr.v4.runtime.atn; + +import org.antlr.v4.runtime.misc.NotNull; +import org.antlr.v4.runtime.misc.Nullable; + +public class LexerATNConfig extends ATNConfig { + /** Capture lexer action we traverse */ + public int lexerActionIndex = -1; // TOOD: move to subclass + + public LexerATNConfig(@NotNull ATNState state, + int alt, + @Nullable PredictionContext context) + { + super(state, alt, context, SemanticContext.NONE); + } + + public LexerATNConfig(@NotNull LexerATNConfig c, @NotNull ATNState state) { + super(c, state, c.context, c.semanticContext); + this.lexerActionIndex = c.lexerActionIndex; + } + + public LexerATNConfig(@NotNull LexerATNConfig c, @NotNull ATNState state, + @NotNull SemanticContext semanticContext) { + super(c, state, c.context, semanticContext); + this.lexerActionIndex = c.lexerActionIndex; + } + + public LexerATNConfig(@NotNull LexerATNConfig c, @NotNull ATNState state, + int actionIndex) + { + super(c, state, c.context, c.semanticContext); + this.lexerActionIndex = actionIndex; + } + + public LexerATNConfig(@NotNull LexerATNConfig c, @NotNull ATNState state, + @Nullable PredictionContext context) { + super(c, state, context, c.semanticContext); + this.lexerActionIndex = c.lexerActionIndex; + } + +} 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 dff8a3966..e5db900e7 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java @@ -73,7 +73,7 @@ public class LexerATNSimulator extends ATNSimulator { protected int line = 0; protected int charPos = -1; protected DFAState dfaState; - protected ATNConfig config; + protected LexerATNConfig config; protected void reset() { index = -1; @@ -384,7 +384,7 @@ public class LexerATNSimulator extends ATNSimulator { Transition trans = c.state.transition(ti); ATNState target = getReachableTarget(trans, t); if ( target!=null ) { - closure(new ATNConfig(c, target), reach); + closure(new LexerATNConfig((LexerATNConfig)c, target), reach); } } } @@ -396,7 +396,7 @@ public class LexerATNSimulator extends ATNSimulator { reach, prevAccept.config, prevAccept.index); } for (int ci=0; ci