forked from jasder/antlr
Merge branch 'master' of github.com:antlr/antlr4
This commit is contained in:
commit
b58eb66774
|
@ -567,6 +567,10 @@ public class Generator {
|
|||
"aa",
|
||||
"",
|
||||
"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",
|
||||
"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);
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
@Test
|
||||
public void testSingleTokenDeletion() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue