diff --git a/tool/src/org/antlr/v4/tool/interp/ParserInterpreter.java b/tool/src/org/antlr/v4/tool/interp/ParserInterpreter.java index a118f4a99..ecf1a78c5 100644 --- a/tool/src/org/antlr/v4/tool/interp/ParserInterpreter.java +++ b/tool/src/org/antlr/v4/tool/interp/ParserInterpreter.java @@ -101,14 +101,6 @@ public class ParserInterpreter { parser.sharedContextCache); } - public synchronized int predictATN(@NotNull DFA dfa, @NotNull TokenStream input, - @Nullable ParserRuleContext outerContext, - boolean useContext) - { - // sync to ensure this entry doesn't race for dfa access - return atnSimulator.predictATN(dfa, input, outerContext); - } - public int adaptivePredict(@NotNull TokenStream input, int decision, @Nullable ParserRuleContext outerContext) { diff --git a/tool/test/org/antlr/v4/test/TestATNParserPrediction.java b/tool/test/org/antlr/v4/test/TestATNParserPrediction.java index 1839df6e2..e1286a31f 100644 --- a/tool/test/org/antlr/v4/test/TestATNParserPrediction.java +++ b/tool/test/org/antlr/v4/test/TestATNParserPrediction.java @@ -489,11 +489,7 @@ public class TestATNParserPrediction extends BaseTest { // ParserATNSimulator interp = new ParserATNSimulator(atn); TokenStream input = new IntTokenStream(types); ParserInterpreter interp = new ParserInterpreter(g, input); - DecisionState startState = atn.decisionToState.get(decision); - DFA dfa = new DFA(startState, decision); - int alt = interp.predictATN(dfa, input, ParserRuleContext.EMPTY, false); - - System.out.println(dot.getDOT(dfa, false)); + int alt = interp.adaptivePredict(input, decision, ParserRuleContext.EMPTY); assertEquals(expectedAlt, alt); @@ -507,44 +503,6 @@ public class TestATNParserPrediction extends BaseTest { assertEquals(expectedAlt, alt); } - public synchronized DFA getDFA(LexerGrammar lg, Grammar g, String ruleName, - String inputString, ParserRuleContext ctx) - { - // sync to ensure multiple tests don't race on dfa access - Tool.internalOption_ShowATNConfigsInDFA = true; - ATN lexatn = createATN(lg, true); - LexerATNSimulator lexInterp = new LexerATNSimulator(lexatn,null,null); - - semanticProcess(lg); - g.importVocab(lg); - semanticProcess(g); - - ParserATNFactory f = new ParserATNFactory(g); - ATN atn = f.createATN(); - -// DOTGenerator dot = new DOTGenerator(g); -// System.out.println(dot.getDOT(atn.ruleToStartState.get(g.getRule("a")))); -// System.out.println(dot.getDOT(atn.ruleToStartState.get(g.getRule("b")))); -// System.out.println(dot.getDOT(atn.ruleToStartState.get(g.getRule("e")))); - - ParserATNSimulator interp = - new ParserATNSimulator(atn, new DFA[atn.getNumberOfDecisions()],null); - IntegerList types = getTokenTypesViaATN(inputString, lexInterp); - System.out.println(types); - TokenStream input = new IntTokenStream(types); - try { - DecisionState startState = atn.decisionToState.get(0); - DFA dfa = new DFA(startState); -// Rule r = g.getRule(ruleName); - //ATNState startState = atn.ruleToStartState.get(r); - interp.predictATN(dfa, input, ctx); - } - catch (NoViableAltException nvae) { - nvae.printStackTrace(System.err); - } - return null; - } - public void checkDFAConstruction(LexerGrammar lg, Grammar g, int decision, String[] inputString, String[] dfaString) {