added unit test

This commit is contained in:
Terence Parr 2012-11-03 10:57:16 -07:00
parent a9d4aeab71
commit c8a9ed6d30
1 changed files with 13 additions and 0 deletions

View File

@ -73,6 +73,19 @@ public class TestLexerExec extends BaseTest {
assertNull(stderrDuringParse);
}
@Test
public void testNonGreedyTermination2() throws Exception {
String grammar =
"lexer grammar L;\n"
+ "STRING : '\"' ('\"\"' | .)+? '\"';";
String found = execLexer("L.g4", grammar, "L", "\"hi\"\"mom\"");
assertEquals(
"[@0,0:3='\"hi\"\"mom\"',<1>,1:0]\n" +
"[@2,9:8='<EOF>',<-1>,1:9]\n", found);
assertNull(stderrDuringParse);
}
@Test
public void testGreedyOptional() throws Exception {
String grammar =