Suppress one unnecessary type of error recovery variation

If we already have a stack version in which, for example,
a `function_call` is skipped, don't create another stack
version in which that `function_call` is reduced to an
`expression`, and then the `expression` is skipped. That
doesn't improve the error recovery at all, but adds to the
branching factor of the parse stack and makes things harder
to debug.
This commit is contained in:
Max Brunsfeld 2017-02-07 21:55:09 -08:00
parent 819b63e78d
commit 93d7a75b09
2 changed files with 3 additions and 2 deletions

View file

@ -550,7 +550,7 @@ static StackPopResult parser__reduce(Parser *self, StackVersion version,
// If this pop operation terminated at the end of an error region, then
// create two stack versions: one in which the parent node is interpreted
// normally, and one in which the parent node is skipped.
if (state == ERROR_STATE && allow_skipping) {
if (state == ERROR_STATE && allow_skipping && child_count > 1) {
StackVersion other_version = ts_stack_copy_version(self->stack, slice.version);
ts_stack_push(self->stack, other_version, parent, false, ERROR_STATE);