From 0fe6496b8bf1f5b79ddc37e4e3d11d9a33629ba9 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 30 Aug 2018 10:41:59 -0700 Subject: [PATCH] Allow version count to temporarily exceed the max during reductions --- src/runtime/parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index 0906f754..efeab009 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -36,6 +36,7 @@ #define SYM_NAME(symbol) ts_language_symbol_name(self->language, symbol) static const unsigned MAX_VERSION_COUNT = 6; +static const unsigned MAX_VERSION_COUNT_OVERFLOW = 4; static const unsigned MAX_SUMMARY_DEPTH = 16; static const unsigned MAX_COST_DIFFERENCE = 16 * ERROR_COST_PER_SKIPPED_TREE; @@ -633,7 +634,7 @@ static StackVersion ts_parser__reduce(TSParser *self, StackVersion version, TSSy // Error recovery can sometimes cause lots of stack versions to merge, // such that a single pop operation can produce a lots of slices. // Avoid creating too many stack versions in that situation. - if (i > 0 && slice_version > MAX_VERSION_COUNT) { + if (i > 0 && slice_version > MAX_VERSION_COUNT + MAX_VERSION_COUNT_OVERFLOW) { ts_stack_remove_version(self->stack, slice_version); ts_subtree_array_delete(&self->tree_pool, &slice.subtrees); removed_version_count++;