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 50756148b..a46aed91f 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java @@ -261,7 +261,7 @@ public class LexerATNSimulator extends ATNSimulator { return failOrAccept(prevAccept, input, reach, t); } - protected int execATN(@NotNull CharStream input, @NotNull ATNConfigSet s0, @Nullable DFAState ds0) { + protected int execATN(@NotNull CharStream input, @NotNull ATNConfigSet s0, @NotNull DFAState ds0) { //System.out.println("enter exec index "+input.index()+" from "+s0); @NotNull ATNConfigSet closure = s0; @@ -271,6 +271,7 @@ public class LexerATNSimulator extends ATNSimulator { traceLookahead1(); int t = input.LA(1); + @NotNull DFAState s = ds0; // s is current/from DFA state while ( true ) { // while more work @@ -325,6 +326,7 @@ public class LexerATNSimulator extends ATNSimulator { // we reached state associated with closure for sure, so // make sure it's defined. worst case, we define s0 from // start state configs. + @NotNull DFAState from = s != null ? s : addDFAState(closure); // we got nowhere on t, don't throw out this knowledge; it'd // cause a failover from DFA later. @@ -387,7 +389,7 @@ public class LexerATNSimulator extends ATNSimulator { * we can reach upon input {@code t}. Parameter {@code reach} is a return * parameter. */ - protected void getReachableConfigSet(ATNConfigSet closure, ATNConfigSet reach, int t) { + protected void getReachableConfigSet(@NotNull ATNConfigSet closure, @NotNull ATNConfigSet reach, int t) { // this is used to skip processing for configs which have a lower priority // than a config that already reached an accept state for the same rule int skipAlt = ATN.INVALID_ALT_NUMBER; @@ -417,6 +419,7 @@ public class LexerATNSimulator extends ATNSimulator { } } + @NotNull protected ATNConfigSet processAcceptConfigs(@NotNull CharStream input, @NotNull ATNConfigSet reach) { if ( debug ) { System.out.format("processAcceptConfigs: reach=%s, prevAccept=%s, prevIndex=%d\n", @@ -668,6 +671,7 @@ public class LexerATNSimulator extends ATNSimulator { settings.dfaState = null; } + @NotNull protected DFAState addDFAEdge(@NotNull DFAState from, int t, @NotNull ATNConfigSet q) @@ -681,6 +685,8 @@ public class LexerATNSimulator extends ATNSimulator { */ boolean suppressEdge = q.hasSemanticContext; q.hasSemanticContext = false; + + @NotNull DFAState to = addDFAState(q); // even if we can add the states, we can't add an edge for labels out of range @@ -715,7 +721,7 @@ public class LexerATNSimulator extends ATNSimulator { configuration containing an ATN rule stop state. Later, when traversing the DFA, we will know which rule to accept. */ - @Nullable + @NotNull protected DFAState addDFAState(@NotNull ATNConfigSet configs) { /* the lexer evaluates predicates on-the-fly; by this point configs * should not contain any configurations with unevaluated predicates.