forked from jasder/antlr
add unit test that reproduces issue #670
This commit is contained in:
parent
0c2a693638
commit
64f6e196b2
|
@ -385,7 +385,8 @@ public class TestCompositeGrammars extends BaseTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a regression test for antlr/antlr4#670 "exception when importing
|
* This is a regression test for antlr/antlr4#670 "exception when importing
|
||||||
* grammar".
|
* grammar". I think this one always worked but I found that a different
|
||||||
|
* Java grammar caused an error and so I made the testImportLeftRecursiveGrammar() test below.
|
||||||
* https://github.com/antlr/antlr4/issues/670
|
* https://github.com/antlr/antlr4/issues/670
|
||||||
*/
|
*/
|
||||||
// TODO: migrate to test framework
|
// TODO: migrate to test framework
|
||||||
|
@ -403,4 +404,32 @@ public class TestCompositeGrammars extends BaseTest {
|
||||||
assertEquals("", found);
|
assertEquals("", found);
|
||||||
assertNull(stderrDuringParse);
|
assertNull(stderrDuringParse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a regression test for antlr/antlr4#670 "exception when importing
|
||||||
|
* grammar".
|
||||||
|
* https://github.com/antlr/antlr4/issues/670
|
||||||
|
*/
|
||||||
|
// TODO: migrate to test framework
|
||||||
|
@Test
|
||||||
|
public void testImportLeftRecursiveGrammar() throws Exception {
|
||||||
|
String slave =
|
||||||
|
"grammar Java;\n" +
|
||||||
|
"e : '(' e ')'\n" +
|
||||||
|
" | e '=' e\n" +
|
||||||
|
" | ID\n" +
|
||||||
|
" ;\n" +
|
||||||
|
"ID : [a-z]+ ;\n";
|
||||||
|
String master =
|
||||||
|
"grammar T;\n" +
|
||||||
|
"import Java;\n" +
|
||||||
|
"s : e ;\n";
|
||||||
|
|
||||||
|
System.out.println("dir "+tmpdir);
|
||||||
|
mkdir(tmpdir);
|
||||||
|
writeFile(tmpdir, "Java.g4", slave);
|
||||||
|
String found = execParser("T.g4", master, "TParser", "TLexer", "s", "a=b", debug);
|
||||||
|
assertEquals("", found);
|
||||||
|
assertNull(stderrDuringParse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue