From 16ca03855679fb743c71883ec14b882f5c27cd18 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 22 Jun 2016 21:05:05 -0700 Subject: [PATCH] Don't accept input with errors on the stack --- src/runtime/parser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index 293783f3..2668ace6 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -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;