diff --git a/include/tree_sitter/runtime.h b/include/tree_sitter/runtime.h index 30d58b7f..52c5fd79 100644 --- a/include/tree_sitter/runtime.h +++ b/include/tree_sitter/runtime.h @@ -7,7 +7,7 @@ extern "C" { #include -typedef int ts_symbol; +typedef unsigned int ts_symbol; static const ts_symbol ts_builtin_sym_error = 0; static const ts_symbol ts_builtin_sym_end = 1; diff --git a/src/runtime/stack.c b/src/runtime/stack.c index 528ef5f7..39a0d1c9 100644 --- a/src/runtime/stack.c +++ b/src/runtime/stack.c @@ -72,8 +72,7 @@ ts_tree * ts_stack_reduce(ts_stack *stack, ts_symbol symbol, int immediate_child size += ts_tree_offset(child) + ts_tree_size(child); } - ts_symbol symbol = ts_tree_symbol(child); - if (symbol >= 0 && hidden_symbol_flags[symbol]) { + if (hidden_symbol_flags[ts_tree_symbol(child)]) { size_t grandchild_count; ts_tree_children(child, &grandchild_count); child_count += grandchild_count; @@ -90,9 +89,7 @@ ts_tree * ts_stack_reduce(ts_stack *stack, ts_symbol symbol, int immediate_child ts_tree *child = stack->entries[new_stack_size + i].node; immediate_children[i] = child; - - ts_symbol symbol = ts_tree_symbol(child); - if (symbol >= 0 && hidden_symbol_flags[symbol]) { + if (hidden_symbol_flags[ts_tree_symbol(child)]) { size_t grandchild_count; ts_tree ** grandchildren = ts_tree_children(child, &grandchild_count); memcpy(children + child_index, grandchildren, (grandchild_count * sizeof(ts_tree *)));