Return the correct tree when starting parser interpreter at an LR rule (fixes #461)

This commit is contained in:
Sam Harwell 2014-02-06 20:47:02 -06:00
parent d498292680
commit 72a65093e0
1 changed files with 10 additions and 2 deletions

View File

@ -148,8 +148,16 @@ public class ParserInterpreter extends Parser {
case ATNState.RULE_STOP :
// pop; return from rule
if ( _ctx.isEmpty() ) {
exitRule();
return rootContext;
if (startRuleStartState.isPrecedenceRule) {
ParserRuleContext result = _ctx;
Pair<ParserRuleContext, Integer> parentContext = _parentContextStack.pop();
unrollRecursionContexts(parentContext.a);
return result;
}
else {
exitRule();
return rootContext;
}
}
visitRuleStopState(p);