Rename ts_tree_assign_parents -> ts_tree_balance

This commit is contained in:
Max Brunsfeld 2018-05-10 09:13:46 -07:00
parent a53d0b43a1
commit 59694e60fa
3 changed files with 4 additions and 3 deletions

View file

@ -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();

View file

@ -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) {

View file

@ -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 *);