diff --git a/templates/c++/lr.h b/templates/c++/lr.h index b96158b..e9e01cd 100644 --- a/templates/c++/lr.h +++ b/templates/c++/lr.h @@ -150,6 +150,13 @@ Value {{name}}::parse() { stateStack.push(TABLE[stateStack.top()][verr] >> 2); valueStack.emplace(std::move(errorVal)); + + while (tok != {{name}}_Symbol::T_EOF && (TABLE[stateStack.top()][static_cast(tok.symbol)] & 0x3) == ERROR) { + tok = lex(); + } + if ((TABLE[stateStack.top()][static_cast(tok.symbol)] & 0x3) == ERROR) { + throw SyntaxError("Syntax error: could not recover"); + } } break; case SHIFT: