From 4ec94e0fae90ce2988a25d1c9ff1e3717c8f6a12 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 21 Jan 2015 19:35:33 -0600 Subject: [PATCH] TestParseTrees for Java is working --- .../antlr4/runtime/test/templates/Index.stg | 3 +- .../test/templates/ParseTrees/2AltLoop.stg | 29 +++ .../test/templates/ParseTrees/2Alts.stg | 29 +++ .../test/templates/ParseTrees/ExtraToken.stg | 34 ++++ .../test/templates/ParseTrees/Index.stg | 13 ++ .../test/templates/ParseTrees/NoViableAlt.stg | 33 ++++ .../test/templates/ParseTrees/RuleRef.stg | 31 ++++ .../test/templates/ParseTrees/Sync.stg | 33 ++++ .../test/templates/ParseTrees/Token2.stg | 29 +++ .../ParseTrees/TokenAndRuleContextString.stg | 31 ++++ .../org/antlr/v4/test/rt/gen/Generator.java | 38 ---- .../rt/gen/grammars/ParseTrees/2AltLoop.st | 11 -- .../test/rt/gen/grammars/ParseTrees/2Alts.st | 11 -- .../rt/gen/grammars/ParseTrees/ExtraToken.st | 14 -- .../rt/gen/grammars/ParseTrees/NoViableAlt.st | 14 -- .../rt/gen/grammars/ParseTrees/RuleRef.st | 13 -- .../test/rt/gen/grammars/ParseTrees/Sync.st | 13 -- .../test/rt/gen/grammars/ParseTrees/Token2.st | 11 -- .../ParseTrees/TokenAndRuleContextString.st | 12 -- .../antlr/v4/test/rt/java/TestParseTrees.java | 171 ------------------ .../antlr/v4/test/runtime/java/Java.test.stg | 23 ++- 21 files changed, 277 insertions(+), 319 deletions(-) create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/2AltLoop.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/2Alts.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/ExtraToken.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Index.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/NoViableAlt.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/RuleRef.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Sync.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Token2.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/TokenAndRuleContextString.stg delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/2AltLoop.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/2Alts.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/ExtraToken.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/NoViableAlt.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/RuleRef.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/Sync.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/Token2.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/TokenAndRuleContextString.st delete mode 100644 tool/test/org/antlr/v4/test/rt/java/TestParseTrees.java diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/Index.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/Index.stg index fc7033c0a..290dd85fe 100644 --- a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/Index.stg +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/Index.stg @@ -1,5 +1,6 @@ TestFolders ::= [ - "CompositeLexers": [] + "CompositeLexers": [], + "ParseTrees": [] ] //TestTemplates ::= [ diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/2AltLoop.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/2AltLoop.stg new file mode 100644 index 000000000..cc8640c74 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/2AltLoop.stg @@ -0,0 +1,29 @@ +TestType() ::= "Parser" + +Grammar ::= [ + "T": {} +] + +Input() ::= "xyyxyxz" + +Rule() ::= "s" + +Output() ::= << +(a x y y x y x z)<\n> +>> + +Errors() ::= "" + +grammar(grammarName) ::= << +grammar ; +s +@init { + +} +@after { + +} + : r=a ; +a : ('x' | 'y')* 'z' + ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/2Alts.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/2Alts.stg new file mode 100644 index 000000000..2f1a40049 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/2Alts.stg @@ -0,0 +1,29 @@ +TestType() ::= "Parser" + +Grammar ::= [ + "T": {} +] + +Input() ::= "y" + +Rule() ::= "s" + +Output() ::= << +(a y)<\n> +>> + +Errors() ::= "" + +grammar(grammarName) ::= << +grammar ; +s +@init { + +} +@after { + +} + : r=a ; +a : 'x' | 'y' + ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/ExtraToken.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/ExtraToken.stg new file mode 100644 index 000000000..90e85755e --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/ExtraToken.stg @@ -0,0 +1,34 @@ +TestType() ::= "Parser" + +Grammar ::= [ + "T": {} +] + +Input() ::= "xzy" + +Rule() ::= "s" + +Output() ::= << +(a x z y)<\n> +>> + +Errors() ::= << +line 1:1 extraneous input 'z' expecting 'y'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +s +@init { + +} +@after { + +} + : r=a ; +a : 'x' 'y' + ; +Z : 'z' + ; + +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Index.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Index.stg new file mode 100644 index 000000000..3aba0b7ae --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Index.stg @@ -0,0 +1,13 @@ +//TestFolders ::= [ +//] + +TestTemplates ::= [ + "TokenAndRuleContextString": [], + "Token2": [], + "2Alts": [], + "2AltLoop": [], + "RuleRef": [], + "ExtraToken": [], + "NoViableAlt": [], + "Sync": [] +] diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/NoViableAlt.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/NoViableAlt.stg new file mode 100644 index 000000000..967c1ff98 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/NoViableAlt.stg @@ -0,0 +1,33 @@ +TestType() ::= "Parser" + +Grammar ::= [ + "T": {} +] + +Input() ::= "z" + +Rule() ::= "s" + +Output() ::= << +(a z)<\n> +>> + +Errors() ::= << +line 1:0 mismatched input 'z' expecting {'x', 'y'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +s +@init { + +} +@after { + +} + : r=a ; +a : 'x' | 'y' + ; +Z : 'z' + ; + >> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/RuleRef.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/RuleRef.stg new file mode 100644 index 000000000..b7eeadf12 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/RuleRef.stg @@ -0,0 +1,31 @@ +TestType() ::= "Parser" + +Grammar ::= [ + "T": {} +] + +Input() ::= "yx" + +Rule() ::= "s" + +Output() ::= << +(a (b y) x)<\n> +>> + +Errors() ::= "" + +grammar(grammarName) ::= << +grammar ; +s +@init { + +} +@after { + +} + : r=a ; +a : b 'x' + ; +b : 'y' + ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Sync.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Sync.stg new file mode 100644 index 000000000..405412dc3 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Sync.stg @@ -0,0 +1,33 @@ +TestType() ::= "Parser" + +Grammar ::= [ + "T": {} +] + +Input() ::= "xzyy!" + +Rule() ::= "s" + +Output() ::= << +(a x z y y !)<\n> +>> + +Errors() ::= << +line 1:1 extraneous input 'z' expecting {'y', '!'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +s +@init { + +} +@after { + +} + : r=a ; +a : 'x' 'y'* '!' + ; +Z : 'z' + ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Token2.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Token2.stg new file mode 100644 index 000000000..050412cba --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/Token2.stg @@ -0,0 +1,29 @@ +TestType() ::= "Parser" + +Grammar ::= [ + "T": {} +] + +Input() ::= "xy" + +Rule() ::= "s" + +Output() ::= << +(a x y)<\n> +>> + +Errors() ::= "" + +grammar(grammarName) ::= << +grammar ; +s +@init { + +} +@after { + +} + : r=a ; +a : 'x' 'y' + ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/TokenAndRuleContextString.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/TokenAndRuleContextString.stg new file mode 100644 index 000000000..ecde00502 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParseTrees/TokenAndRuleContextString.stg @@ -0,0 +1,31 @@ +TestType() ::= "Parser" + +Grammar ::= [ + "T": {} +] + +Input() ::= "x" + +Rule() ::= "s" + +Output() ::= << +[a, s] +(a x)<\n> +>> + +Errors() ::= "" + +grammar(grammarName) ::= << +grammar ; +s +@init { + +} +@after { + +} + : r=a ; +a : 'x' { + +} ; +>> diff --git a/tool/test/org/antlr/v4/test/rt/gen/Generator.java b/tool/test/org/antlr/v4/test/rt/gen/Generator.java index 8842ad4ed..de96f054d 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/Generator.java +++ b/tool/test/org/antlr/v4/test/rt/gen/Generator.java @@ -158,7 +158,6 @@ public class Generator { list.add(buildListeners()); list.add(buildParserErrors()); list.add(buildParserExec()); - list.add(buildParseTrees()); list.add(buildSemPredEvalLexer()); list.add(buildSemPredEvalParser()); return list; @@ -437,43 +436,6 @@ public class Generator { return file; } - private JUnitTestFile buildParseTrees() throws Exception { - JUnitTestFile file = new JUnitTestFile("ParseTrees"); - file.addParserTest(input, "TokenAndRuleContextString", "T", "s", - "x", - "[a, s]\n(a x)\n", - null); - file.addParserTest(input, "Token2", "T", "s", - "xy", - "(a x y)\n", - null); - file.addParserTest(input, "2Alts", "T", "s", - "y", - "(a y)\n", - null); - file.addParserTest(input, "2AltLoop", "T", "s", - "xyyxyxz", - "(a x y y x y x z)\n", - null); - file.addParserTest(input, "RuleRef", "T", "s", - "yx", - "(a (b y) x)\n", - null); - file.addParserTest(input, "ExtraToken", "T", "s", - "xzy", - "(a x z y)\n", // ERRORs not shown. z is colored red in tree view - "line 1:1 extraneous input 'z' expecting 'y'\n"); - file.addParserTest(input, "NoViableAlt", "T", "s", - "z", - "(a z)\n", - "line 1:0 mismatched input 'z' expecting {'x', 'y'}\n"); - file.addParserTest(input, "Sync", "T", "s", - "xzyy!", - "(a x z y y !)\n", - "line 1:1 extraneous input 'z' expecting {'y', '!'}\n"); - return file; - } - private JUnitTestFile buildParserErrors() throws Exception { JUnitTestFile file = new JUnitTestFile("ParserErrors"); file.addParserTest(input, "TokenMismatch", "T", "a", diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/2AltLoop.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/2AltLoop.st deleted file mode 100644 index 332b4b8a0..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/2AltLoop.st +++ /dev/null @@ -1,11 +0,0 @@ -grammar ; -s -@init { - -} -@after { - -} - : r=a ; -a : ('x' | 'y')* 'z' - ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/2Alts.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/2Alts.st deleted file mode 100644 index aa5e44672..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/2Alts.st +++ /dev/null @@ -1,11 +0,0 @@ -grammar ; -s -@init { - -} -@after { - -} - : r=a ; -a : 'x' | 'y' - ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/ExtraToken.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/ExtraToken.st deleted file mode 100644 index a7620ea07..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/ExtraToken.st +++ /dev/null @@ -1,14 +0,0 @@ -grammar ; -s -@init { - -} -@after { - -} - : r=a ; -a : 'x' 'y' - ; -Z : 'z' - ; - diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/NoViableAlt.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/NoViableAlt.st deleted file mode 100644 index be903effe..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/NoViableAlt.st +++ /dev/null @@ -1,14 +0,0 @@ -grammar ; -s -@init { - -} -@after { - -} - : r=a ; -a : 'x' | 'y' - ; -Z : 'z' - ; - \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/RuleRef.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/RuleRef.st deleted file mode 100644 index e35e3a801..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/RuleRef.st +++ /dev/null @@ -1,13 +0,0 @@ -grammar ; -s -@init { - -} -@after { - -} - : r=a ; -a : b 'x' - ; -b : 'y' - ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/Sync.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/Sync.st deleted file mode 100644 index 9584bedb0..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/Sync.st +++ /dev/null @@ -1,13 +0,0 @@ -grammar ; -s -@init { - -} -@after { - -} - : r=a ; -a : 'x' 'y'* '!' - ; -Z : 'z' - ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/Token2.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/Token2.st deleted file mode 100644 index 979f30694..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/Token2.st +++ /dev/null @@ -1,11 +0,0 @@ -grammar ; -s -@init { - -} -@after { - -} - : r=a ; -a : 'x' 'y' - ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/TokenAndRuleContextString.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/TokenAndRuleContextString.st deleted file mode 100644 index 8903bd5bb..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParseTrees/TokenAndRuleContextString.st +++ /dev/null @@ -1,12 +0,0 @@ -grammar ; -s -@init { - -} -@after { - -} - : r=a ; -a : 'x' { - -} ; diff --git a/tool/test/org/antlr/v4/test/rt/java/TestParseTrees.java b/tool/test/org/antlr/v4/test/rt/java/TestParseTrees.java deleted file mode 100644 index 63dc712f5..000000000 --- a/tool/test/org/antlr/v4/test/rt/java/TestParseTrees.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.antlr.v4.test.rt.java; - -import org.junit.Test; -import static org.junit.Assert.*; - -public class TestParseTrees extends BaseTest { - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testTokenAndRuleContextString() throws Exception { - String grammar = "grammar T;\n" + - "s\n" + - "@init {\n" + - "setBuildParseTree(true);\n" + - "}\n" + - "@after {\n" + - "System.out.println($r.ctx.toStringTree(this));\n" + - "}\n" + - " : r=a ;\n" + - "a : 'x' { \n" + - "System.out.println(getRuleInvocationStack());\n" + - "} ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "x", false); - assertEquals("[a, s]\n(a x)\n", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testToken2() throws Exception { - String grammar = "grammar T;\n" + - "s\n" + - "@init {\n" + - "setBuildParseTree(true);\n" + - "}\n" + - "@after {\n" + - "System.out.println($r.ctx.toStringTree(this));\n" + - "}\n" + - " : r=a ;\n" + - "a : 'x' 'y'\n" + - " ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "xy", false); - assertEquals("(a x y)\n", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void test2Alts() throws Exception { - String grammar = "grammar T;\n" + - "s\n" + - "@init {\n" + - "setBuildParseTree(true);\n" + - "}\n" + - "@after {\n" + - "System.out.println($r.ctx.toStringTree(this));\n" + - "}\n" + - " : r=a ;\n" + - "a : 'x' | 'y'\n" + - " ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "y", false); - assertEquals("(a y)\n", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void test2AltLoop() throws Exception { - String grammar = "grammar T;\n" + - "s\n" + - "@init {\n" + - "setBuildParseTree(true);\n" + - "}\n" + - "@after {\n" + - "System.out.println($r.ctx.toStringTree(this));\n" + - "}\n" + - " : r=a ;\n" + - "a : ('x' | 'y')* 'z'\n" + - " ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "xyyxyxz", false); - assertEquals("(a x y y x y x z)\n", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testRuleRef() throws Exception { - String grammar = "grammar T;\n" + - "s\n" + - "@init {\n" + - "setBuildParseTree(true);\n" + - "}\n" + - "@after {\n" + - "System.out.println($r.ctx.toStringTree(this));\n" + - "}\n" + - " : r=a ;\n" + - "a : b 'x'\n" + - " ;\n" + - "b : 'y' \n" + - " ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "yx", false); - assertEquals("(a (b y) x)\n", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testExtraToken() throws Exception { - String grammar = "grammar T;\n" + - "s\n" + - "@init {\n" + - "setBuildParseTree(true);\n" + - "}\n" + - "@after {\n" + - "System.out.println($r.ctx.toStringTree(this));\n" + - "}\n" + - " : r=a ;\n" + - "a : 'x' 'y'\n" + - " ;\n" + - "Z : 'z' \n" + - " ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "xzy", false); - assertEquals("(a x z y)\n", found); - assertEquals("line 1:1 extraneous input 'z' expecting 'y'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testNoViableAlt() throws Exception { - String grammar = "grammar T;\n" + - "s\n" + - "@init {\n" + - "setBuildParseTree(true);\n" + - "}\n" + - "@after {\n" + - "System.out.println($r.ctx.toStringTree(this));\n" + - "}\n" + - " : r=a ;\n" + - "a : 'x' | 'y'\n" + - " ;\n" + - "Z : 'z' \n" + - " ;\n" + - " "; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "z", false); - assertEquals("(a z)\n", found); - assertEquals("line 1:0 mismatched input 'z' expecting {'x', 'y'}\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSync() throws Exception { - String grammar = "grammar T;\n" + - "s\n" + - "@init {\n" + - "setBuildParseTree(true);\n" + - "}\n" + - "@after {\n" + - "System.out.println($r.ctx.toStringTree(this));\n" + - "}\n" + - " : r=a ;\n" + - "a : 'x' 'y'* '!'\n" + - " ;\n" + - "Z : 'z' \n" + - " ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "xzyy!", false); - assertEquals("(a x z y y !)\n", found); - assertEquals("line 1:1 extraneous input 'z' expecting {'y', '!'}\n", this.stderrDuringParse); - } - - -} \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/runtime/java/Java.test.stg b/tool/test/org/antlr/v4/test/runtime/java/Java.test.stg index 195477f28..e0927e5a0 100644 --- a/tool/test/org/antlr/v4/test/runtime/java/Java.test.stg +++ b/tool/test/org/antlr/v4/test/runtime/java/Java.test.stg @@ -74,6 +74,8 @@ writeLines(textLines) ::= <% ParserTestMethod(test) ::= << @Test public void test() throws Exception { + mkdir(tmpdir); + = };separator="\\n\" +\n", wrap, anchor>"; @@ -84,19 +86,20 @@ public void test() throws Exception { };separator="\n", wrap, anchor>!> - mkdir(tmpdir); - ", );}; separator="\n", anchor> - writeFile(tmpdir, "" - - String grammar = };separator="\\n\" +\n", wrap, anchor>"; - - String found = execParser(".g4", grammar, "Parser", "Lexer", "", "", ); - assertEquals("", found); - - assertEquals("", this.stderrDuringParse); +; + + + + String input =; + String found = execParser(".g4", grammar, "Parser", "Lexer", "", input, ); + assertEquals(, found); + + assertEquals(, this.stderrDuringParse); assertNull(this.stderrDuringParse); + }> } >>