From dcf3beb393353084e88bff481e9d77ec3fccc3e0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 29 Aug 2016 09:31:52 -0700 Subject: [PATCH] Abandon parse versions with > 1 error more than the best version --- src/runtime/parser.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index 4dea281a..26aadc10 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -377,7 +377,8 @@ static bool ts_parser__better_version_exists(TSParser *self, unsigned error_cost = ts_stack_error_cost(self->stack, i); unsigned error_depth = ts_stack_error_depth(self->stack, i); - if ((error_depth > my_error_depth && error_cost >= my_error_cost) || + if ((error_depth > my_error_depth + 1) || + (error_depth > my_error_depth && error_cost >= my_error_cost) || (my_error_depth == 0 && error_cost > my_error_cost) || (error_depth == my_error_depth && error_cost >= my_error_cost + ERROR_COST_THRESHOLD)) { @@ -386,7 +387,8 @@ static bool ts_parser__better_version_exists(TSParser *self, continue; } - if ((my_error_depth > error_depth && my_error_cost >= error_cost) || + if ((my_error_depth > error_depth + 1) || + (my_error_depth > error_depth && my_error_cost >= error_cost) || (error_depth == 0 && my_error_cost > error_cost) || (my_error_depth == error_depth && my_error_cost >= error_cost + ERROR_COST_THRESHOLD)) {