Merge branch 'fix-196'
This commit is contained in:
commit
f75878b3e6
|
@ -1229,7 +1229,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
{
|
||||
if ( debug ) System.out.println("closure("+config.toString(parser,true)+")");
|
||||
|
||||
if ( !closureBusy.add(config) ) return; // avoid infinite recursion
|
||||
if ( depth != 0 && !closureBusy.add(config) ) return; // avoid infinite recursion
|
||||
|
||||
if ( config.state instanceof RuleStopState ) {
|
||||
// We hit rule end. If we have context info, use it
|
||||
|
|
|
@ -77,6 +77,30 @@ public class TestSemPredEvalParser extends BaseTest {
|
|||
assertEquals(expecting, stderrDuringParse);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a regression test for antlr/antlr4#196
|
||||
* "element+ in expression grammar doesn't parse properly"
|
||||
* https://github.com/antlr/antlr4/issues/196
|
||||
*/
|
||||
@Test public void testAtomWithClosureInTranslatedLRRule() throws Exception {
|
||||
String grammar =
|
||||
"grammar T;\n" +
|
||||
"start : e[0] EOF;\n" +
|
||||
"e[int _p]\n" +
|
||||
" : ( 'a'\n" +
|
||||
" | 'b'+\n" +
|
||||
" )\n" +
|
||||
" ( {3 >= $_p}? '+' e[4]\n" +
|
||||
" )*\n" +
|
||||
" ;\n";
|
||||
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "start",
|
||||
"a+b+a", false);
|
||||
String expecting = "";
|
||||
assertEquals(expecting, found);
|
||||
assertNull(stderrDuringParse);
|
||||
}
|
||||
|
||||
@Test public void testValidateInDFA() throws Exception {
|
||||
String grammar =
|
||||
"grammar T;\n" +
|
||||
|
|
Loading…
Reference in New Issue