From 59694e60faebfbf8f19f0c31f7d751f02c5debf0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 10 May 2018 09:13:46 -0700 Subject: [PATCH] Rename ts_tree_assign_parents -> ts_tree_balance --- src/runtime/parser.c | 2 +- src/runtime/tree.c | 3 ++- src/runtime/tree.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index cac6c9e1..f1ba0d16 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -1336,7 +1336,7 @@ Tree *parser_parse(Parser *self, TSInput input, Tree *old_tree, bool halt_on_err reusable_node_delete(&reusable_node); ts_stack_clear(self->stack); parser__set_cached_token(self, 0, NULL, NULL); - ts_tree_assign_parents(self->finished_tree, &self->tree_pool, self->language); + ts_tree_balance(self->finished_tree, &self->tree_pool, self->language); LOG("done"); LOG_TREE(); diff --git a/src/runtime/tree.c b/src/runtime/tree.c index 85707c1b..e80a1f68 100644 --- a/src/runtime/tree.c +++ b/src/runtime/tree.c @@ -208,11 +208,12 @@ static void ts_tree__compress(Tree *self, unsigned count, const TSLanguage *lang } } -void ts_tree_assign_parents(Tree *self, TreePool *pool, const TSLanguage *language) { +void ts_tree_balance(Tree *self, TreePool *pool, const TSLanguage *language) { array_clear(&pool->tree_stack); array_push(&pool->tree_stack, self); while (pool->tree_stack.size > 0) { Tree *tree = array_pop(&pool->tree_stack); + assert(tree); if (tree->repeat_depth > 0) { if (tree->children.contents[0]->repeat_depth > tree->children.contents[1]->repeat_depth) { diff --git a/src/runtime/tree.h b/src/runtime/tree.h index 0eb6f929..ce96e41d 100644 --- a/src/runtime/tree.h +++ b/src/runtime/tree.h @@ -99,7 +99,7 @@ void ts_tree_release(TreePool *, Tree *tree); bool ts_tree_eq(const Tree *tree1, const Tree *tree2); int ts_tree_compare(const Tree *tree1, const Tree *tree2); void ts_tree_set_children(Tree *, TreeArray *, const TSLanguage *); -void ts_tree_assign_parents(Tree *, TreePool *, const TSLanguage *); +void ts_tree_balance(Tree *, TreePool *, const TSLanguage *); void ts_tree_edit(Tree *, const TSInputEdit *edit); char *ts_tree_string(const Tree *, const TSLanguage *, bool include_all); void ts_tree_print_dot_graph(const Tree *, const TSLanguage *, FILE *);