Generate method stub so external calls directly to LR rules do not require the precedence argument
This commit is contained in:
parent
df0bbf42e1
commit
6eb8111756
|
@ -359,7 +359,11 @@ LeftRecursiveRuleFunction(currentRule,code,locals,ruleCtx,altLabelCtxs,
|
||||||
<ruleCtx>
|
<ruleCtx>
|
||||||
<altLabelCtxs:{l | <altLabelCtxs.(l)>}; separator="\n">
|
<altLabelCtxs:{l | <altLabelCtxs.(l)>}; separator="\n">
|
||||||
|
|
||||||
<if(currentRule.modifiers)><currentRule.modifiers:{f | <f> }><else>public final <endif><currentRule.ctxType> <currentRule.name>(int _p<currentRule.args:{a | , <a>}>) throws RecognitionException {
|
<if(currentRule.modifiers)><currentRule.modifiers:{f | <f> }><else>public final <endif><currentRule.ctxType> <currentRule.name>(<currentRule.args; separator=", ">) throws RecognitionException {
|
||||||
|
return <currentRule.name>(0<currentRule.args:{a | , <a.name>}>);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <currentRule.ctxType> <currentRule.name>(int _p<currentRule.args:{a | , <a>}>) throws RecognitionException {
|
||||||
ParserRuleContext _parentctx = _ctx;
|
ParserRuleContext _parentctx = _ctx;
|
||||||
int _parentState = getState();
|
int _parentState = getState();
|
||||||
<currentRule.ctxType> _localctx = new <currentRule.ctxType>(_ctx, _parentState<currentRule.args:{a | , <a.name>}>);
|
<currentRule.ctxType> _localctx = new <currentRule.ctxType>(_ctx, _parentState<currentRule.args:{a | , <a.name>}>);
|
||||||
|
|
|
@ -73,7 +73,6 @@ public class TestLeftRecursion extends BaseTest {
|
||||||
@Test public void testDirectCallToLeftRecursiveRule() throws Exception {
|
@Test public void testDirectCallToLeftRecursiveRule() throws Exception {
|
||||||
String grammar =
|
String grammar =
|
||||||
"grammar T;\n" +
|
"grammar T;\n" +
|
||||||
"@parser::members{public AContext a() { return a(0); }}\n" +
|
|
||||||
"a @after {System.out.println($ctx.toStringTree(this));} : a ID\n" +
|
"a @after {System.out.println($ctx.toStringTree(this));} : a ID\n" +
|
||||||
" | ID" +
|
" | ID" +
|
||||||
" ;\n" +
|
" ;\n" +
|
||||||
|
|
Loading…
Reference in New Issue