diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/descriptors/TraceParserATN/LL2Trace.txt b/runtime-testsuite/resources/org/antlr/v4/test/runtime/descriptors/TraceParserATN/LL2Trace.txt new file mode 100644 index 00000000000..7887e9c53d2 --- /dev/null +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/descriptors/TraceParserATN/LL2Trace.txt @@ -0,0 +1,52 @@ +[type] +Parser + +[grammar] +grammar T; +s : t EOF ; +t : ID ';' | ID '.' ; +ID : [a-zA-Z]+ ; +WS : [ \r\n\t]+ -> skip ; + +[start] +s + +[input] +xyz. + +[output] +"""adaptivePredict decision 0 exec LA(1)==ID<3> line 1:0 +predictATN decision 0 exec LA(1)==ID<3>, outerContext=[t s] +closure((7,1,[$])) +closure((9,2,[$])) +adding new DFA state: 0:[(7,1,[$]), (9,2,[$])] +execATN decision 0 exec LA(1)==ID<3> line 1:0 +s0 = 0:[(7,1,[$]), (9,2,[$])] +in computeReachSet, starting closure: [(7,1,[$]), (9,2,[$])] +testing ID<3> at (7,1,[$]) +testing ID<3> at (9,2,[$]) +closure((8,1,[$])) +closure((10,2,[$])) +SLL altSubSets=[{1}, {2}], configs=[(8,1,[$]), (10,2,[$])], predict=0, allSubsetsConflict=false, conflictingAlts={1, 2} +EDGE 0:[(7,1,[$]), (9,2,[$])] -> -1:[(8,1,[$]), (10,2,[$])] upon ID<3> +adding new DFA state: 1:[(8,1,[$]), (10,2,[$])] +DFA= +s0-ID->s1 + +in computeReachSet, starting closure: [(8,1,[$]), (10,2,[$])] +testing '.'<2> at (8,1,[$]) +testing '.'<2> at (10,2,[$]) +SLL altSubSets=[{2}], configs=[(12,2,[$])], predict=2, allSubsetsConflict=false, conflictingAlts={2} +EDGE 1:[(8,1,[$]), (10,2,[$])] -> -1:[(12,2,[$])],uniqueAlt=2=>2 upon '.'<2> +adding new DFA state: 2:[(12,2,[$])],uniqueAlt=2=>2 +DFA= +s0-ID->s1 +s1-'.'->:s2=>2 + +DFA after predictATN: s0-ID->s1 +s1-'.'->:s2=>2 + +""" + +[flags] +traceATN diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/java/JavaRunner.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/java/JavaRunner.java index b78b2bf1d88..dfbff618dd6 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/java/JavaRunner.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/java/JavaRunner.java @@ -185,14 +185,21 @@ private ExecutedState execCommon(JavaCompiledState compiledState) { stdoutReader.start(); stderrReader.start(); + PrintStream saveStdout = System.out; + ByteArrayOutputStream captureNormalStdout = new ByteArrayOutputStream(); + System.setOut(new PrintStream(captureNormalStdout)); + recognizeMethod.invoke(null, new File(getTempDirPath(), "input").getAbsolutePath(), new PrintStream(stdoutOut), new PrintStream(stderrOut)); + System.setOut(saveStdout); + stdoutOut.close(); stderrOut.close(); stdoutReader.join(); stderrReader.join(); - output = stdoutReader.toString(); + // include normal stdout to get print statements from ATN simulation debugging + output = stdoutReader.toString() + captureNormalStdout; errors = stderrReader.toString(); } catch (Exception ex) { exception = ex;