forked from jasder/antlr
test added to check a user issue
This commit is contained in:
parent
3f9cb4b12f
commit
2e06ed8360
|
@ -567,6 +567,10 @@ public class Generator {
|
||||||
"aa",
|
"aa",
|
||||||
"",
|
"",
|
||||||
"line 1:1 mismatched input 'a' expecting 'b'\n");
|
"line 1:1 mismatched input 'a' expecting 'b'\n");
|
||||||
|
file.addParserTest(input, "TokenMismatch2", "T", "stat",
|
||||||
|
"( ~FORCE_ERROR~ ",
|
||||||
|
"",
|
||||||
|
"line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n");
|
||||||
file.addParserTest(input, "SingleTokenDeletion", "T", "a",
|
file.addParserTest(input, "SingleTokenDeletion", "T", "a",
|
||||||
"aab",
|
"aab",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
grammar <grammarName>;
|
||||||
|
|
||||||
|
stat: ( '(' expr? ')' )? EOF ;
|
||||||
|
expr: ID '=' STR ;
|
||||||
|
|
||||||
|
ERR : '~FORCE_ERROR~' ;
|
||||||
|
ID : [a-zA-Z]+ ;
|
||||||
|
STR : '"' ~["]* '"' ;
|
||||||
|
WS : [ \t\r\n]+ -> skip ;
|
|
@ -17,6 +17,23 @@ public class TestParserErrors extends BaseTest {
|
||||||
assertEquals("line 1:1 mismatched input 'a' expecting 'b'\n", this.stderrDuringParse);
|
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 testTokenMismatch2() throws Exception {
|
||||||
|
String grammar = "grammar T;\n" +
|
||||||
|
"\n" +
|
||||||
|
"stat: ( '(' expr? ')' )? EOF ;\n" +
|
||||||
|
"expr: ID '=' STR ;\n" +
|
||||||
|
"\n" +
|
||||||
|
"ERR : '~FORCE_ERROR~' ;\n" +
|
||||||
|
"ID : [a-zA-Z]+ ;\n" +
|
||||||
|
"STR : '\"' ~[\"]* '\"' ;\n" +
|
||||||
|
"WS : [ \\t\\r\\n]+ -> skip ;";
|
||||||
|
String found = execParser("T.g4", grammar, "TParser", "TLexer", "stat", "( ~FORCE_ERROR~ ", false);
|
||||||
|
assertEquals("", found);
|
||||||
|
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||||
|
}
|
||||||
|
|
||||||
/* this file and method are generated, any edit will be overwritten by the next generation */
|
/* this file and method are generated, any edit will be overwritten by the next generation */
|
||||||
@Test
|
@Test
|
||||||
public void testSingleTokenDeletion() throws Exception {
|
public void testSingleTokenDeletion() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue