Skipping tokens while recovering errors in the generated parser
This commit is contained in:
parent
4b1b0ab9e0
commit
b777ffc52d
|
@ -150,6 +150,13 @@ Value {{name}}<Value>::parse() {
|
||||||
|
|
||||||
stateStack.push(TABLE[stateStack.top()][verr] >> 2);
|
stateStack.push(TABLE[stateStack.top()][verr] >> 2);
|
||||||
valueStack.emplace(std::move(errorVal));
|
valueStack.emplace(std::move(errorVal));
|
||||||
|
|
||||||
|
while (tok != {{name}}_Symbol::T_EOF && (TABLE[stateStack.top()][static_cast<std::uint64_t>(tok.symbol)] & 0x3) == ERROR) {
|
||||||
|
tok = lex();
|
||||||
|
}
|
||||||
|
if ((TABLE[stateStack.top()][static_cast<std::uint64_t>(tok.symbol)] & 0x3) == ERROR) {
|
||||||
|
throw SyntaxError("Syntax error: could not recover");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHIFT:
|
case SHIFT:
|
||||||
|
|
Loading…
Reference in New Issue