fix #3042 in Cpp runtime

This commit is contained in:
Eric Vergnaud 2021-01-23 18:47:54 +08:00
parent e8dfc30f91
commit 559d526648
1 changed files with 8 additions and 10 deletions

View File

@ -100,18 +100,16 @@ void LL1Analyzer::_LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext>
} }
if (ctx != PredictionContext::EMPTY) { if (ctx != PredictionContext::EMPTY) {
// run thru all possible stack tops in ctx bool removed = calledRuleStack.test(s->ruleIndex);
calledRuleStack[s->ruleIndex] = false;
auto onExit = finally([removed, &calledRuleStack, s] {
if (removed) {
calledRuleStack.set(s->ruleIndex);
}
});
// run thru all possible stack tops in ctx
for (size_t i = 0; i < ctx->size(); i++) { for (size_t i = 0; i < ctx->size(); i++) {
ATNState *returnState = _atn.states[ctx->getReturnState(i)]; ATNState *returnState = _atn.states[ctx->getReturnState(i)];
bool removed = calledRuleStack.test(returnState->ruleIndex);
auto onExit = finally([removed, &calledRuleStack, returnState] {
if (removed) {
calledRuleStack.set(returnState->ruleIndex);
}
});
calledRuleStack[returnState->ruleIndex] = false;
_LOOK(returnState, stopState, ctx->getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF); _LOOK(returnState, stopState, ctx->getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
} }
return; return;