TestParserErrors for Java is working
This commit is contained in:
parent
c11b384b1d
commit
113b72da53
|
@ -1,6 +1,7 @@
|
|||
TestFolders ::= [
|
||||
"CompositeLexers": [],
|
||||
"LexerExec": [],
|
||||
"ParserErrors": [],
|
||||
"ParseTrees": [],
|
||||
"SemPredEvalLexer": [],
|
||||
"SemPredEvalParser": []
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "ac"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
conjured=[@-1,-1:-1='\<missing 'b'>',\<2>,1:1]<\n>
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 missing 'b' at 'c'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' x='b' {<Append("\"conjured=\"","$x"):writeln()>} 'c' ;
|
||||
>>
|
|
@ -0,0 +1,26 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "ad"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
conjured=[@-1,-1:-1='\<missing 'b'>',\<2>,1:1]<\n>
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 missing {'b', 'c'} at 'd'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' x=('b'|'c') {<Append("\"conjured=\"","$x"):writeln()>} 'd' ;
|
||||
>>
|
|
@ -0,0 +1,29 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "abab"
|
||||
|
||||
Rule() ::= "s"
|
||||
|
||||
Output() ::= <<
|
||||
abab<\n>
|
||||
>>
|
||||
|
||||
Errors() ::= ""
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::members{
|
||||
<DeclareContextListGettersFunction()>
|
||||
}
|
||||
s : (a | b)+;
|
||||
a : 'a' {<write("'a'")>};
|
||||
b : 'b' {<write("'b'")>};
|
||||
>>
|
|
@ -0,0 +1,19 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Rule() ::= "start"
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
start : expr EOF;
|
||||
expr : 'x'
|
||||
| expr expr
|
||||
;
|
||||
>>
|
|
@ -0,0 +1,7 @@
|
|||
import "DuplicatedLeftRecursiveCall.stg"
|
||||
|
||||
Input() ::= "xx"
|
||||
|
||||
Output() ::= ""
|
||||
|
||||
Errors() ::= ""
|
|
@ -0,0 +1,7 @@
|
|||
import "DuplicatedLeftRecursiveCall.stg"
|
||||
|
||||
Input() ::= "xxx"
|
||||
|
||||
Output() ::= ""
|
||||
|
||||
Errors() ::= ""
|
|
@ -0,0 +1,7 @@
|
|||
import "DuplicatedLeftRecursiveCall.stg"
|
||||
|
||||
Input() ::= "xxxx"
|
||||
|
||||
Output() ::= ""
|
||||
|
||||
Errors() ::= ""
|
|
@ -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": []
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "x:x"
|
||||
|
||||
Rule() ::= "start"
|
||||
|
||||
Output() ::= ""
|
||||
|
||||
Errors() ::= ""
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
start : ID ':' expr;
|
||||
expr : primary expr? {<Pass()>} | expr '->' ID;
|
||||
primary : ID;
|
||||
ID : [a-z]+;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= ""
|
||||
|
||||
Rule() ::= "start"
|
||||
|
||||
Output() ::= ""
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:0 missing ID at '\<EOF>'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
start : ID+;
|
||||
ID : [a-z]+;
|
||||
>>
|
|
@ -1,3 +1,24 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "dog and software"
|
||||
|
||||
Rule() ::= "start"
|
||||
|
||||
Output() ::= <<
|
||||
{'hardware', 'software'}<\n>
|
||||
>>
|
||||
|
||||
Errors() ::= ""
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
start : animal (AND acClass)? service EOF;
|
||||
animal : (DOG | CAT );
|
||||
|
@ -12,3 +33,4 @@ acClass
|
|||
@init
|
||||
{<GetExpectedTokenNames():writeln()>}
|
||||
: ;
|
||||
>>
|
|
@ -0,0 +1,28 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "ae"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 no viable alternative at input 'ae'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' 'b'
|
||||
| 'a' 'c'
|
||||
;
|
||||
q : 'e' ;
|
||||
>>
|
|
@ -0,0 +1,28 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "abe"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:2 no viable alternative at input 'abe'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' 'b'* 'c'
|
||||
| 'a' 'b' 'd'
|
||||
;
|
||||
q : 'e' ;
|
||||
>>
|
|
@ -0,0 +1,28 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "aaae"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:3 no viable alternative at input 'aaae'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a'+ 'b'
|
||||
| 'a'+ 'c'
|
||||
;
|
||||
q : 'e' ;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "aacabc"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 extraneous input 'a' expecting {'b', 'c'}<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' 'b'* 'c';
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "aacabc"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 extraneous input 'a' expecting {'b', 'z', 'c'}<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'z'{<Pass()>})* 'c';
|
||||
>>
|
|
@ -0,0 +1,26 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<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 <grammarName>;
|
||||
a : 'a' 'b'* 'c' ;
|
||||
>>
|
|
@ -0,0 +1,26 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<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 <grammarName>;
|
||||
a : 'a' ('b'|'z'{<Pass()>})* 'c' ;
|
||||
>>
|
|
@ -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": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "a."
|
||||
|
||||
Rule() ::= "s"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 mismatched input '.' expecting '!'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
s : e '!' ;
|
||||
e : 'a' 'b'
|
||||
| 'a'
|
||||
;
|
||||
DOT : '.' ;
|
||||
WS : [ \t\r\n]+ -> skip;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "ad"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 missing {'b', 'c'} at 'd'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'c') 'd' ;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "aab"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 extraneous input 'a' expecting 'b'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' 'b' ;
|
||||
>>
|
|
@ -0,0 +1,26 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "aabc"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 extraneous input 'a' expecting {\<EOF>, 'b'}
|
||||
line 1:3 token recognition error at: 'c'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' 'b'* ;
|
||||
>>
|
|
@ -0,0 +1,26 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "aabc"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 extraneous input 'a' expecting {\<EOF>, 'b', 'z'}
|
||||
line 1:3 token recognition error at: 'c'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'z'{<Pass()>})*;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "ababbc"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:2 extraneous input 'a' expecting {'b', 'c'}<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' 'b'* 'c' ;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "ababbc"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'z'{<Pass()>})* 'c' ;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "aab"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 extraneous input 'a' expecting {'b', 'c'}<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'c') ;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "ac"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 missing 'b' at 'c'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' 'b' 'c' ;
|
||||
>>
|
|
@ -0,0 +1,25 @@
|
|||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "aa"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:1 mismatched input 'a' expecting 'b'<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : 'a' 'b' ;
|
||||
>>
|
|
@ -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='<missing 'b'>',<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='<missing 'b'>',<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 {<EOF>, '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 {<EOF>, '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 '<EOF>'\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",
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' x='b' {<Append("\"conjured=\"","$x"):writeln()>} 'c' ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' x=('b'|'c') {<Append("\"conjured=\"","$x"):writeln()>} 'd' ;
|
|
@ -1,7 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
@parser::members{
|
||||
<DeclareContextListGettersFunction()>
|
||||
}
|
||||
s : (a | b)+;
|
||||
a : 'a' {<write("'a'")>};
|
||||
b : 'b' {<write("'b'")>};
|
|
@ -1,5 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
start : expr EOF;
|
||||
expr : 'x'
|
||||
| expr expr
|
||||
;
|
|
@ -1,5 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
start : ID ':' expr;
|
||||
expr : primary expr? {<Pass()>} | expr '->' ID;
|
||||
primary : ID;
|
||||
ID : [a-z]+;
|
|
@ -1,3 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
start : ID+;
|
||||
ID : [a-z]+;
|
|
@ -1,5 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b'
|
||||
| 'a' 'c'
|
||||
;
|
||||
q : 'e' ;
|
|
@ -1,5 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b'* 'c'
|
||||
| 'a' 'b' 'd'
|
||||
;
|
||||
q : 'e' ;
|
|
@ -1,5 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a'+ 'b'
|
||||
| 'a'+ 'c'
|
||||
;
|
||||
q : 'e' ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b'* 'c';
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'z'{<Pass()>})* 'c';
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b'* 'c' ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'z'{<Pass()>})* 'c' ;
|
|
@ -1,7 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
s : e '!' ;
|
||||
e : 'a' 'b'
|
||||
| 'a'
|
||||
;
|
||||
DOT : '.' ;
|
||||
WS : [ \t\r\n]+ -> skip;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'c') 'd' ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b' ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b'* ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'z'{<Pass()>})*;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b'* 'c' ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'z'{<Pass()>})* 'c' ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' ('b'|'c') ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b' 'c' ;
|
|
@ -1,2 +0,0 @@
|
|||
grammar <grammarName>;
|
||||
a : 'a' 'b' ;
|
|
@ -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='<missing 'b'>',<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='<missing 'b'>',<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 {<EOF>, '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 {<EOF>, '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 '<EOF>'\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<? extends AContext> a = s.a();\n" +
|
||||
" List<? extends BContext> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue