Don't accept input with errors on the stack

This commit is contained in:
Max Brunsfeld 2016-06-22 21:05:05 -07:00
parent b40c0326dc
commit 16ca038556

View file

@ -909,7 +909,8 @@ static bool ts_parser__recover(TSParser *self, StackVersion version,
LOG_ACTION("recover_eof");
TreeArray children = array_new();
TSTree *parent = ts_tree_make_error_node(&children);
return ts_parser__push(self, version, parent, 1);
CHECK(ts_parser__push(self, version, parent, 1));
return ts_parser__accept(self, version);
}
unsigned my_error_cost = ts_stack_error_cost(self->stack, version);
@ -1006,6 +1007,8 @@ static bool ts_parser__consume_lookahead(TSParser *self, StackVersion version,
}
case TSParseActionTypeAccept: {
if (ts_stack_error_depth(self->stack, version) > 0)
continue;
LOG_ACTION("accept");
CHECK(ts_parser__accept(self, version));
return true;