From 113b72da53fcec576fab54c1b574bc11388d7a5c Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 25 Jan 2015 20:50:06 -0600 Subject: [PATCH] TestParserErrors for Java is working --- .../antlr4/runtime/test/templates/Index.stg | 1 + .../ParserErrors/ConjuringUpToken.stg | 26 ++ .../ParserErrors/ConjuringUpTokenFromSet.stg | 26 ++ .../ParserErrors/ContextListGetters.stg | 29 ++ .../DuplicatedLeftRecursiveCall.stg | 19 ++ .../DuplicatedLeftRecursiveCall_1.stg | 7 + .../DuplicatedLeftRecursiveCall_2.stg | 7 + .../DuplicatedLeftRecursiveCall_3.stg | 7 + .../test/templates/ParserErrors/Index.stg | 31 ++ .../ParserErrors/InvalidATNStateRemoval.stg | 25 ++ .../ParserErrors/InvalidEmptyInput.stg | 25 ++ .../templates/ParserErrors/LL1ErrorInfo.stg | 22 ++ .../test/templates/ParserErrors/LL2.stg | 28 ++ .../test/templates/ParserErrors/LL3.stg | 28 ++ .../test/templates/ParserErrors/LLStar.stg | 28 ++ .../MultiTokenDeletionBeforeLoop.stg | 25 ++ .../MultiTokenDeletionBeforeLoop2.stg | 25 ++ .../MultiTokenDeletionDuringLoop.stg | 26 ++ .../MultiTokenDeletionDuringLoop2.stg | 26 ++ .../ParserErrors/NoViableAltAvoidance.stg | 35 ++ .../ParserErrors/SingleSetInsertion.stg | 25 ++ .../ParserErrors/SingleTokenDeletion.stg | 25 ++ .../SingleTokenDeletionBeforeLoop.stg | 26 ++ .../SingleTokenDeletionBeforeLoop2.stg | 26 ++ .../SingleTokenDeletionDuringLoop.stg | 25 ++ .../SingleTokenDeletionDuringLoop2.stg | 25 ++ .../SingleTokenDeletionExpectingSet.stg | 25 ++ .../ParserErrors/SingleTokenInsertion.stg | 25 ++ .../templates/ParserErrors/TokenMismatch.stg | 25 ++ .../org/antlr/v4/test/rt/gen/Generator.java | 110 ------ .../grammars/ParserErrors/ConjuringUpToken.st | 2 - .../ParserErrors/ConjuringUpTokenFromSet.st | 2 - .../ParserErrors/ContextListGetters.st | 7 - .../DuplicatedLeftRecursiveCall.st | 5 - .../ParserErrors/InvalidATNStateRemoval.st | 5 - .../ParserErrors/InvalidEmptyInput.st | 3 - .../test/rt/gen/grammars/ParserErrors/LL2.st | 5 - .../test/rt/gen/grammars/ParserErrors/LL3.st | 5 - .../rt/gen/grammars/ParserErrors/LLStar.st | 5 - .../MultiTokenDeletionBeforeLoop.st | 2 - .../MultiTokenDeletionBeforeLoop2.st | 2 - .../MultiTokenDeletionDuringLoop.st | 2 - .../MultiTokenDeletionDuringLoop2.st | 2 - .../ParserErrors/NoViableAltAvoidance.st | 7 - .../ParserErrors/SingleSetInsertion.st | 2 - .../ParserErrors/SingleTokenDeletion.st | 2 - .../SingleTokenDeletionBeforeLoop.st | 2 - .../SingleTokenDeletionBeforeLoop2.st | 2 - .../SingleTokenDeletionDuringLoop.st | 2 - .../SingleTokenDeletionDuringLoop2.st | 2 - .../SingleTokenDeletionExpectingSet.st | 2 - .../ParserErrors/SingleTokenInsertion.st | 2 - .../grammars/ParserErrors/TokenMismatch.st | 2 - .../v4/test/rt/java/TestParserErrors.java | 312 ------------------ 54 files changed, 673 insertions(+), 494 deletions(-) create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ConjuringUpToken.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ConjuringUpTokenFromSet.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ContextListGetters.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_1.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_2.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_3.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/Index.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/InvalidATNStateRemoval.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/InvalidEmptyInput.stg rename tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL1ErrorInfo.st => antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL1ErrorInfo.stg (53%) create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL2.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL3.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LLStar.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionBeforeLoop.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionBeforeLoop2.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionDuringLoop.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionDuringLoop2.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/NoViableAltAvoidance.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleSetInsertion.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletion.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionBeforeLoop.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionBeforeLoop2.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionDuringLoop.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionDuringLoop2.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionExpectingSet.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenInsertion.stg create mode 100644 antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/TokenMismatch.stg delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpToken.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpTokenFromSet.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ContextListGetters.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/DuplicatedLeftRecursiveCall.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/InvalidATNStateRemoval.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/InvalidEmptyInput.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL2.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL3.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LLStar.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionBeforeLoop.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionBeforeLoop2.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionDuringLoop.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionDuringLoop2.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/NoViableAltAvoidance.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleSetInsertion.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletion.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionBeforeLoop.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionBeforeLoop2.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionDuringLoop.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionDuringLoop2.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionExpectingSet.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenInsertion.st delete mode 100644 tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/TokenMismatch.st delete mode 100644 tool/test/org/antlr/v4/test/rt/java/TestParserErrors.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 46cef550d..ae5518f62 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,6 +1,7 @@ TestFolders ::= [ "CompositeLexers": [], "LexerExec": [], + "ParserErrors": [], "ParseTrees": [], "SemPredEvalLexer": [], "SemPredEvalParser": [] diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ConjuringUpToken.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ConjuringUpToken.stg new file mode 100644 index 000000000..62928d675 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ConjuringUpToken.stg @@ -0,0 +1,26 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "ac" + +Rule() ::= "a" + +Output() ::= << +conjured=[@-1,-1:-1='\',\<2>,1:1]<\n> +>> + +Errors() ::= << +line 1:1 missing 'b' at 'c'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' x='b' {} 'c' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ConjuringUpTokenFromSet.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ConjuringUpTokenFromSet.stg new file mode 100644 index 000000000..b0f6ad7d4 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ConjuringUpTokenFromSet.stg @@ -0,0 +1,26 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "ad" + +Rule() ::= "a" + +Output() ::= << +conjured=[@-1,-1:-1='\',\<2>,1:1]<\n> +>> + +Errors() ::= << +line 1:1 missing {'b', 'c'} at 'd'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' x=('b'|'c') {} 'd' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ContextListGetters.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ContextListGetters.stg new file mode 100644 index 000000000..47b8e1494 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/ContextListGetters.stg @@ -0,0 +1,29 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "abab" + +Rule() ::= "s" + +Output() ::= << +abab<\n> +>> + +Errors() ::= "" + +grammar(grammarName) ::= << +grammar ; +@parser::members{ + +} +s : (a | b)+; +a : 'a' {}; +b : 'b' {}; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall.stg new file mode 100644 index 000000000..95ce24f73 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall.stg @@ -0,0 +1,19 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Rule() ::= "start" + +grammar(grammarName) ::= << +grammar ; +start : expr EOF; +expr : 'x' + | expr expr + ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_1.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_1.stg new file mode 100644 index 000000000..261f25afe --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_1.stg @@ -0,0 +1,7 @@ +import "DuplicatedLeftRecursiveCall.stg" + +Input() ::= "xx" + +Output() ::= "" + +Errors() ::= "" diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_2.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_2.stg new file mode 100644 index 000000000..31dfe0c08 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_2.stg @@ -0,0 +1,7 @@ +import "DuplicatedLeftRecursiveCall.stg" + +Input() ::= "xxx" + +Output() ::= "" + +Errors() ::= "" diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_3.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_3.stg new file mode 100644 index 000000000..cd446a55f --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/DuplicatedLeftRecursiveCall_3.stg @@ -0,0 +1,7 @@ +import "DuplicatedLeftRecursiveCall.stg" + +Input() ::= "xxxx" + +Output() ::= "" + +Errors() ::= "" diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/Index.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/Index.stg new file mode 100644 index 000000000..827813ed5 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/Index.stg @@ -0,0 +1,31 @@ +//TestFolders ::= [ +//] + +TestTemplates ::= [ + "TokenMismatch": [], + "SingleTokenDeletion": [], + "SingleTokenDeletionExpectingSet": [], + "SingleTokenInsertion": [], + "ConjuringUpToken": [], + "SingleSetInsertion": [], + "ConjuringUpTokenFromSet": [], + "LL2": [], + "LL3": [], + "LLStar": [], + "SingleTokenDeletionBeforeLoop": [], + "MultiTokenDeletionBeforeLoop": [], + "SingleTokenDeletionDuringLoop": [], + "MultiTokenDeletionDuringLoop": [], + "SingleTokenDeletionBeforeLoop2": [], + "MultiTokenDeletionBeforeLoop2": [], + "SingleTokenDeletionDuringLoop2": [], + "MultiTokenDeletionDuringLoop2": [], + "LL1ErrorInfo": [], + "InvalidEmptyInput": [], + "ContextListGetters": [], + "DuplicatedLeftRecursiveCall_1": [], + "DuplicatedLeftRecursiveCall_2": [], + "DuplicatedLeftRecursiveCall_3": [], + "InvalidATNStateRemoval": [], + "NoViableAltAvoidance": [] +] diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/InvalidATNStateRemoval.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/InvalidATNStateRemoval.stg new file mode 100644 index 000000000..97e41a6dc --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/InvalidATNStateRemoval.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "x:x" + +Rule() ::= "start" + +Output() ::= "" + +Errors() ::= "" + +grammar(grammarName) ::= << +grammar ; +start : ID ':' expr; +expr : primary expr? {} | expr '->' ID; +primary : ID; +ID : [a-z]+; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/InvalidEmptyInput.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/InvalidEmptyInput.stg new file mode 100644 index 000000000..6fe2f4dd0 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/InvalidEmptyInput.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "" + +Rule() ::= "start" + +Output() ::= "" + +Errors() ::= << +line 1:0 missing ID at '\'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +start : ID+; +ID : [a-z]+; +>> diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL1ErrorInfo.st b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL1ErrorInfo.stg similarity index 53% rename from tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL1ErrorInfo.st rename to antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL1ErrorInfo.stg index ebd21c8b3..99327d9c7 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL1ErrorInfo.st +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL1ErrorInfo.stg @@ -1,3 +1,24 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "dog and software" + +Rule() ::= "start" + +Output() ::= << +{'hardware', 'software'}<\n> +>> + +Errors() ::= "" + +grammar(grammarName) ::= << grammar ; start : animal (AND acClass)? service EOF; animal : (DOG | CAT ); @@ -12,3 +33,4 @@ acClass @init {} : ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL2.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL2.stg new file mode 100644 index 000000000..8476aa6ed --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL2.stg @@ -0,0 +1,28 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "ae" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 no viable alternative at input 'ae'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b' + | 'a' 'c' +; +q : 'e' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL3.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL3.stg new file mode 100644 index 000000000..8337754a6 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LL3.stg @@ -0,0 +1,28 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "abe" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:2 no viable alternative at input 'abe'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b'* 'c' + | 'a' 'b' 'd' +; +q : 'e' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LLStar.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LLStar.stg new file mode 100644 index 000000000..f11e4de37 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/LLStar.stg @@ -0,0 +1,28 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "aaae" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:3 no viable alternative at input 'aaae'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a'+ 'b' + | 'a'+ 'c' +; +q : 'e' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionBeforeLoop.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionBeforeLoop.stg new file mode 100644 index 000000000..de095891c --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionBeforeLoop.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "aacabc" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 extraneous input 'a' expecting {'b', 'c'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b'* 'c'; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionBeforeLoop2.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionBeforeLoop2.stg new file mode 100644 index 000000000..60ab4b695 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionBeforeLoop2.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "aacabc" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 extraneous input 'a' expecting {'b', 'z', 'c'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' ('b'|'z'{})* 'c'; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionDuringLoop.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionDuringLoop.stg new file mode 100644 index 000000000..1ca9c48ae --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionDuringLoop.stg @@ -0,0 +1,26 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "abaaababc" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:2 extraneous input 'a' expecting {'b', 'c'} +line 1:6 extraneous input 'a' expecting {'b', 'c'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b'* 'c' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionDuringLoop2.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionDuringLoop2.stg new file mode 100644 index 000000000..861040252 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/MultiTokenDeletionDuringLoop2.stg @@ -0,0 +1,26 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "abaaababc" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'} +line 1:6 extraneous input 'a' expecting {'b', 'z', 'c'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' ('b'|'z'{})* 'c' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/NoViableAltAvoidance.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/NoViableAltAvoidance.stg new file mode 100644 index 000000000..3bcf4b7af --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/NoViableAltAvoidance.stg @@ -0,0 +1,35 @@ +// "a." matches 'a' to rule e but then realizes '.' won't match. +// previously would cause noviablealt. now prediction pretends to +// have "a' predict 2nd alt of e. Will get syntax error later so +// let it get farther. + +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "a." + +Rule() ::= "s" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 mismatched input '.' expecting '!'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +s : e '!' ; +e : 'a' 'b' + | 'a' + ; +DOT : '.' ; +WS : [ \t\r\n]+ -> skip; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleSetInsertion.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleSetInsertion.stg new file mode 100644 index 000000000..b57901152 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleSetInsertion.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "ad" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 missing {'b', 'c'} at 'd'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' ('b'|'c') 'd' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletion.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletion.stg new file mode 100644 index 000000000..5a3f9502d --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletion.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "aab" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 extraneous input 'a' expecting 'b'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionBeforeLoop.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionBeforeLoop.stg new file mode 100644 index 000000000..a2cebc547 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionBeforeLoop.stg @@ -0,0 +1,26 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "aabc" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 extraneous input 'a' expecting {\, 'b'} +line 1:3 token recognition error at: 'c'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b'* ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionBeforeLoop2.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionBeforeLoop2.stg new file mode 100644 index 000000000..ee06ab0ce --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionBeforeLoop2.stg @@ -0,0 +1,26 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "aabc" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 extraneous input 'a' expecting {\, 'b', 'z'} +line 1:3 token recognition error at: 'c'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' ('b'|'z'{})*; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionDuringLoop.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionDuringLoop.stg new file mode 100644 index 000000000..5c8dab9cd --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionDuringLoop.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "ababbc" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:2 extraneous input 'a' expecting {'b', 'c'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b'* 'c' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionDuringLoop2.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionDuringLoop2.stg new file mode 100644 index 000000000..3eb2df438 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionDuringLoop2.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "ababbc" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' ('b'|'z'{})* 'c' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionExpectingSet.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionExpectingSet.stg new file mode 100644 index 000000000..f79b62665 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenDeletionExpectingSet.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "aab" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 extraneous input 'a' expecting {'b', 'c'}<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' ('b'|'c') ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenInsertion.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenInsertion.stg new file mode 100644 index 000000000..c7338aa3e --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/SingleTokenInsertion.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "ac" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 missing 'b' at 'c'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b' 'c' ; +>> diff --git a/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/TokenMismatch.stg b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/TokenMismatch.stg new file mode 100644 index 000000000..f56bf8c12 --- /dev/null +++ b/antlr4-testgen-maven-plugin/resources/org/antlr4/runtime/test/templates/ParserErrors/TokenMismatch.stg @@ -0,0 +1,25 @@ +TestType() ::= "Parser" + +Options ::= [ + "Debug": false +] + +Grammar ::= [ + "T": {} +] + +Input() ::= "aa" + +Rule() ::= "a" + +Output() ::= << +>> + +Errors() ::= << +line 1:1 mismatched input 'a' expecting 'b'<\n> +>> + +grammar(grammarName) ::= << +grammar ; +a : 'a' 'b' ; +>> 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 125b602c6..0fe82eec0 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/Generator.java +++ b/tool/test/org/antlr/v4/test/rt/gen/Generator.java @@ -155,120 +155,10 @@ public class Generator { list.add(buildLeftRecursion()); list.add(buildLexerErrors()); list.add(buildListeners()); - list.add(buildParserErrors()); list.add(buildParserExec()); return list; } - private JUnitTestFile buildParserErrors() throws Exception { - JUnitTestFile file = new JUnitTestFile("ParserErrors"); - file.addParserTest(input, "TokenMismatch", "T", "a", - "aa", - "", - "line 1:1 mismatched input 'a' expecting 'b'\n"); - file.addParserTest(input, "SingleTokenDeletion", "T", "a", - "aab", - "", - "line 1:1 extraneous input 'a' expecting 'b'\n"); - file.addParserTest(input, "SingleTokenDeletionExpectingSet", "T", "a", - "aab", - "", - "line 1:1 extraneous input 'a' expecting {'b', 'c'}\n"); - file.addParserTest(input, "SingleTokenInsertion", "T", "a", - "ac", - "", - "line 1:1 missing 'b' at 'c'\n"); - file.addParserTest(input, "ConjuringUpToken", "T", "a", - "ac", - "conjured=[@-1,-1:-1='',<2>,1:1]\n", - "line 1:1 missing 'b' at 'c'\n"); - file.addParserTest(input, "SingleSetInsertion", "T", "a", - "ad", - "", - "line 1:1 missing {'b', 'c'} at 'd'\n"); - file.addParserTest(input, "ConjuringUpTokenFromSet", "T", "a", - "ad", - "conjured=[@-1,-1:-1='',<2>,1:1]\n", - "line 1:1 missing {'b', 'c'} at 'd'\n"); - file.addParserTest(input, "LL2", "T", "a", - "ae", - "", - "line 1:1 no viable alternative at input 'ae'\n"); - file.addParserTest(input, "LL3", "T", "a", - "abe", - "", - "line 1:2 no viable alternative at input 'abe'\n"); - file.addParserTest(input, "LLStar", "T", "a", - "aaae", - "", - "line 1:3 no viable alternative at input 'aaae'\n"); - file.addParserTest(input, "SingleTokenDeletionBeforeLoop", "T", "a", - "aabc", - "", - "line 1:1 extraneous input 'a' expecting {, 'b'}\n" + - "line 1:3 token recognition error at: 'c'\n"); - file.addParserTest(input, "MultiTokenDeletionBeforeLoop", "T", "a", - "aacabc", - "", - "line 1:1 extraneous input 'a' expecting {'b', 'c'}\n"); - file.addParserTest(input, "SingleTokenDeletionDuringLoop", "T", "a", - "ababbc", - "", - "line 1:2 extraneous input 'a' expecting {'b', 'c'}\n"); - file.addParserTest(input, "MultiTokenDeletionDuringLoop", "T", "a", - "abaaababc", - "", - "line 1:2 extraneous input 'a' expecting {'b', 'c'}\n" + - "line 1:6 extraneous input 'a' expecting {'b', 'c'}\n"); - file.addParserTest(input, "SingleTokenDeletionBeforeLoop2", "T", "a", - "aabc", - "", - "line 1:1 extraneous input 'a' expecting {, 'b', 'z'}\n" + - "line 1:3 token recognition error at: 'c'\n"); - file.addParserTest(input, "MultiTokenDeletionBeforeLoop2", "T", "a", - "aacabc", - "", - "line 1:1 extraneous input 'a' expecting {'b', 'z', 'c'}\n"); - file.addParserTest(input, "SingleTokenDeletionDuringLoop2", "T", "a", - "ababbc", - "", - "line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}\n"); - file.addParserTest(input, "MultiTokenDeletionDuringLoop2", "T", "a", - "abaaababc", - "", - "line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}\n" + - "line 1:6 extraneous input 'a' expecting {'b', 'z', 'c'}\n"); - file.addParserTest(input, "LL1ErrorInfo", "T", "start", - "dog and software", - "{'hardware', 'software'}\n", - null); - file.addParserTest(input, "InvalidEmptyInput", "T", "start", - "", - "", - "line 1:0 missing ID at ''\n"); - file.addParserTest(input, "ContextListGetters", "T", "s", - "abab", - "abab\n", - null); - file.addParserTestsWithErrors(input, "DuplicatedLeftRecursiveCall", "T", "start", - "xx", "", null, - "xxx", "", null, - "xxxx", "", null); - file.addParserTest(input, "InvalidATNStateRemoval", "T", "start", - "x:x", - "", - null); - // "a." matches 'a' to rule e but then realizes '.' won't match. - // previously would cause noviablealt. now prediction pretends to - // have "a' predict 2nd alt of e. Will get syntax error later so - // let it get farther. - file.addParserTest(input, "NoViableAltAvoidance", "T", "s", - "a.", - "", - "line 1:1 mismatched input '.' expecting '!'\n"); - return file; - } - private JUnitTestFile buildListeners() throws Exception { JUnitTestFile file = new JUnitTestFile("Listeners"); file.addParserTest(input, "Basic", "T", "s", diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpToken.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpToken.st deleted file mode 100644 index c4ba9d33a..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpToken.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' x='b' {} 'c' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpTokenFromSet.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpTokenFromSet.st deleted file mode 100644 index 5030a368d..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpTokenFromSet.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' x=('b'|'c') {} 'd' ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ContextListGetters.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ContextListGetters.st deleted file mode 100644 index 225cb5d9b..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ContextListGetters.st +++ /dev/null @@ -1,7 +0,0 @@ -grammar ; -@parser::members{ - -} -s : (a | b)+; -a : 'a' {}; -b : 'b' {}; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/DuplicatedLeftRecursiveCall.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/DuplicatedLeftRecursiveCall.st deleted file mode 100644 index b0f163958..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/DuplicatedLeftRecursiveCall.st +++ /dev/null @@ -1,5 +0,0 @@ -grammar ; -start : expr EOF; -expr : 'x' - | expr expr - ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/InvalidATNStateRemoval.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/InvalidATNStateRemoval.st deleted file mode 100644 index bd9e2f93f..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/InvalidATNStateRemoval.st +++ /dev/null @@ -1,5 +0,0 @@ -grammar ; -start : ID ':' expr; -expr : primary expr? {} | expr '->' ID; -primary : ID; -ID : [a-z]+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/InvalidEmptyInput.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/InvalidEmptyInput.st deleted file mode 100644 index 7e4e111ee..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/InvalidEmptyInput.st +++ /dev/null @@ -1,3 +0,0 @@ -grammar ; -start : ID+; -ID : [a-z]+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL2.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL2.st deleted file mode 100644 index a6ea5030b..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL2.st +++ /dev/null @@ -1,5 +0,0 @@ -grammar ; -a : 'a' 'b' - | 'a' 'c' -; -q : 'e' ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL3.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL3.st deleted file mode 100644 index 412d44c02..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LL3.st +++ /dev/null @@ -1,5 +0,0 @@ -grammar ; -a : 'a' 'b'* 'c' - | 'a' 'b' 'd' -; -q : 'e' ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LLStar.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LLStar.st deleted file mode 100644 index bc2e46412..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/LLStar.st +++ /dev/null @@ -1,5 +0,0 @@ -grammar ; -a : 'a'+ 'b' - | 'a'+ 'c' -; -q : 'e' ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionBeforeLoop.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionBeforeLoop.st deleted file mode 100644 index d1ee35ca9..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionBeforeLoop.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' 'b'* 'c'; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionBeforeLoop2.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionBeforeLoop2.st deleted file mode 100644 index 1c4c62b21..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionBeforeLoop2.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' ('b'|'z'{})* 'c'; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionDuringLoop.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionDuringLoop.st deleted file mode 100644 index b7417c923..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionDuringLoop.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' 'b'* 'c' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionDuringLoop2.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionDuringLoop2.st deleted file mode 100644 index d0404f1c6..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/MultiTokenDeletionDuringLoop2.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' ('b'|'z'{})* 'c' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/NoViableAltAvoidance.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/NoViableAltAvoidance.st deleted file mode 100644 index 139e3ded2..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/NoViableAltAvoidance.st +++ /dev/null @@ -1,7 +0,0 @@ -grammar ; -s : e '!' ; -e : 'a' 'b' - | 'a' - ; -DOT : '.' ; -WS : [ \t\r\n]+ -> skip; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleSetInsertion.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleSetInsertion.st deleted file mode 100644 index d5f724b4a..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleSetInsertion.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' ('b'|'c') 'd' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletion.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletion.st deleted file mode 100644 index daebfb144..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletion.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' 'b' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionBeforeLoop.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionBeforeLoop.st deleted file mode 100644 index c2b5d9037..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionBeforeLoop.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' 'b'* ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionBeforeLoop2.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionBeforeLoop2.st deleted file mode 100644 index 9169f8f00..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionBeforeLoop2.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' ('b'|'z'{})*; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionDuringLoop.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionDuringLoop.st deleted file mode 100644 index b7417c923..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionDuringLoop.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' 'b'* 'c' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionDuringLoop2.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionDuringLoop2.st deleted file mode 100644 index d0404f1c6..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionDuringLoop2.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' ('b'|'z'{})* 'c' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionExpectingSet.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionExpectingSet.st deleted file mode 100644 index 6280f7599..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenDeletionExpectingSet.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' ('b'|'c') ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenInsertion.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenInsertion.st deleted file mode 100644 index 013403fce..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/SingleTokenInsertion.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' 'b' 'c' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/TokenMismatch.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/TokenMismatch.st deleted file mode 100644 index daebfb144..000000000 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/TokenMismatch.st +++ /dev/null @@ -1,2 +0,0 @@ -grammar ; -a : 'a' 'b' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/java/TestParserErrors.java b/tool/test/org/antlr/v4/test/rt/java/TestParserErrors.java deleted file mode 100644 index 7f376d8f3..000000000 --- a/tool/test/org/antlr/v4/test/rt/java/TestParserErrors.java +++ /dev/null @@ -1,312 +0,0 @@ -package org.antlr.v4.test.rt.java; - -import org.junit.Test; -import static org.junit.Assert.*; - -public class TestParserErrors extends BaseTest { - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testTokenMismatch() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "aa", false); - assertEquals("", found); - assertEquals("line 1:1 mismatched input 'a' expecting 'b'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSingleTokenDeletion() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "aab", false); - assertEquals("", found); - assertEquals("line 1:1 extraneous input 'a' expecting 'b'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSingleTokenDeletionExpectingSet() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' ('b'|'c') ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "aab", false); - assertEquals("", found); - assertEquals("line 1:1 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSingleTokenInsertion() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b' 'c' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ac", false); - assertEquals("", found); - assertEquals("line 1:1 missing 'b' at 'c'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testConjuringUpToken() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' x='b' {System.out.println(\"conjured=\" + $x);} 'c' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ac", false); - assertEquals("conjured=[@-1,-1:-1='',<2>,1:1]\n", found); - assertEquals("line 1:1 missing 'b' at 'c'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSingleSetInsertion() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' ('b'|'c') 'd' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ad", false); - assertEquals("", found); - assertEquals("line 1:1 missing {'b', 'c'} at 'd'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testConjuringUpTokenFromSet() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' x=('b'|'c') {System.out.println(\"conjured=\" + $x);} 'd' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ad", false); - assertEquals("conjured=[@-1,-1:-1='',<2>,1:1]\n", found); - assertEquals("line 1:1 missing {'b', 'c'} at 'd'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testLL2() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b'\n" + - " | 'a' 'c'\n" + - ";\n" + - "q : 'e' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ae", false); - assertEquals("", found); - assertEquals("line 1:1 no viable alternative at input 'ae'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testLL3() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b'* 'c'\n" + - " | 'a' 'b' 'd'\n" + - ";\n" + - "q : 'e' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "abe", false); - assertEquals("", found); - assertEquals("line 1:2 no viable alternative at input 'abe'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testLLStar() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a'+ 'b'\n" + - " | 'a'+ 'c'\n" + - ";\n" + - "q : 'e' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "aaae", false); - assertEquals("", found); - assertEquals("line 1:3 no viable alternative at input 'aaae'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSingleTokenDeletionBeforeLoop() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b'* ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "aabc", false); - assertEquals("", found); - assertEquals("line 1:1 extraneous input 'a' expecting {, 'b'}\nline 1:3 token recognition error at: 'c'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testMultiTokenDeletionBeforeLoop() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b'* 'c';"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "aacabc", false); - assertEquals("", found); - assertEquals("line 1:1 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSingleTokenDeletionDuringLoop() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b'* 'c' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ababbc", false); - assertEquals("", found); - assertEquals("line 1:2 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testMultiTokenDeletionDuringLoop() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' 'b'* 'c' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "abaaababc", false); - assertEquals("", found); - assertEquals("line 1:2 extraneous input 'a' expecting {'b', 'c'}\nline 1:6 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSingleTokenDeletionBeforeLoop2() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' ('b'|'z'{})*;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "aabc", false); - assertEquals("", found); - assertEquals("line 1:1 extraneous input 'a' expecting {, 'b', 'z'}\nline 1:3 token recognition error at: 'c'\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testMultiTokenDeletionBeforeLoop2() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' ('b'|'z'{})* 'c';"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "aacabc", false); - assertEquals("", found); - assertEquals("line 1:1 extraneous input 'a' expecting {'b', 'z', 'c'}\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testSingleTokenDeletionDuringLoop2() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' ('b'|'z'{})* 'c' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ababbc", false); - assertEquals("", found); - assertEquals("line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testMultiTokenDeletionDuringLoop2() throws Exception { - String grammar = "grammar T;\n" + - "a : 'a' ('b'|'z'{})* 'c' ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "abaaababc", false); - assertEquals("", found); - assertEquals("line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}\nline 1:6 extraneous input 'a' expecting {'b', 'z', 'c'}\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testLL1ErrorInfo() throws Exception { - String grammar = "grammar T;\n" + - "start : animal (AND acClass)? service EOF;\n" + - "animal : (DOG | CAT );\n" + - "service : (HARDWARE | SOFTWARE) ;\n" + - "AND : 'and';\n" + - "DOG : 'dog';\n" + - "CAT : 'cat';\n" + - "HARDWARE: 'hardware';\n" + - "SOFTWARE: 'software';\n" + - "WS : ' ' -> skip ;\n" + - "acClass\n" + - "@init\n" + - "{System.out.println(this.getExpectedTokens().toString(this.tokenNames));}\n" + - " : ;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "start", "dog and software", false); - assertEquals("{'hardware', 'software'}\n", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testInvalidEmptyInput() throws Exception { - String grammar = "grammar T;\n" + - "start : ID+;\n" + - "ID : [a-z]+;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "start", "", false); - assertEquals("", found); - assertEquals("line 1:0 missing ID at ''\n", this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testContextListGetters() throws Exception { - String grammar = "grammar T;\n" + - "@parser::members{\n" + - "void foo() {\n" + - " SContext s = null;\n" + - " List a = s.a();\n" + - " List b = s.b();\n" + - "}\n" + - "}\n" + - "s : (a | b)+;\n" + - "a : 'a' {System.out.print('a');};\n" + - "b : 'b' {System.out.print('b');};"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "abab", false); - assertEquals("abab\n", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - String testDuplicatedLeftRecursiveCall(String input) throws Exception { - String grammar = "grammar T;\n" + - "start : expr EOF;\n" + - "expr : 'x'\n" + - " | expr expr\n" + - " ;"; - return execParser("T.g4", grammar, "TParser", "TLexer", "start", input, false); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testDuplicatedLeftRecursiveCall_1() throws Exception { - String found = testDuplicatedLeftRecursiveCall("xx"); - assertEquals("", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testDuplicatedLeftRecursiveCall_2() throws Exception { - String found = testDuplicatedLeftRecursiveCall("xxx"); - assertEquals("", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testDuplicatedLeftRecursiveCall_3() throws Exception { - String found = testDuplicatedLeftRecursiveCall("xxxx"); - assertEquals("", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testInvalidATNStateRemoval() throws Exception { - String grammar = "grammar T;\n" + - "start : ID ':' expr;\n" + - "expr : primary expr? {} | expr '->' ID;\n" + - "primary : ID;\n" + - "ID : [a-z]+;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "start", "x:x", false); - assertEquals("", found); - assertNull(this.stderrDuringParse); - } - - /* this file and method are generated, any edit will be overwritten by the next generation */ - @Test - public void testNoViableAltAvoidance() throws Exception { - String grammar = "grammar T;\n" + - "s : e '!' ;\n" + - "e : 'a' 'b'\n" + - " | 'a'\n" + - " ;\n" + - "DOT : '.' ;\n" + - "WS : [ \\t\\r\\n]+ -> skip;"; - String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", "a.", false); - assertEquals("", found); - assertEquals("line 1:1 mismatched input '.' expecting '!'\n", this.stderrDuringParse); - } - - -} \ No newline at end of file