Start work on javascript grammar
This commit is contained in:
parent
fd226a6bfe
commit
671f1a1ddc
11 changed files with 1695 additions and 10 deletions
|
|
@ -61,7 +61,7 @@ size_t ts_stack_right_position(const ts_stack *stack) {
|
|||
ts_tree * ts_stack_reduce(ts_stack *stack, ts_symbol symbol, int immediate_child_count, const int *collapse_flags) {
|
||||
size_t new_stack_size = stack->size - immediate_child_count;
|
||||
size_t size = 0, offset = 0;
|
||||
|
||||
|
||||
int child_count = 0;
|
||||
for (int i = 0; i < immediate_child_count; i++) {
|
||||
ts_tree *child = stack->entries[new_stack_size + i].node;
|
||||
|
|
@ -84,7 +84,7 @@ ts_tree * ts_stack_reduce(ts_stack *stack, ts_symbol symbol, int immediate_child
|
|||
size_t child_index = 0;
|
||||
ts_tree **children = malloc((child_count + immediate_child_count) * sizeof(ts_tree *));
|
||||
ts_tree **immediate_children = children + child_count;
|
||||
|
||||
|
||||
for (int i = 0; i < immediate_child_count; i++) {
|
||||
ts_tree *child = stack->entries[new_stack_size + i].node;
|
||||
immediate_children[i] = child;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ int ts_tree_equals(const ts_tree *node1, const ts_tree *node2) {
|
|||
size_t count1, count2;
|
||||
ts_tree **children1 = ts_tree_children(node1, &count1);
|
||||
ts_tree **children2 = ts_tree_children(node2, &count2);
|
||||
if (count1 != count2) return 0;
|
||||
if (count1 != count2) return 0;
|
||||
for (size_t i = 0; i < count1; i++)
|
||||
if (!ts_tree_equals(children1[i], children2[i])) return 0;
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ static size_t tree_write_to_string(const ts_tree *tree, const char **symbol_name
|
|||
cursor += tree_write_to_string(children[i], symbol_names, *destination, limit);
|
||||
}
|
||||
cursor += snprintf(*destination, limit, ")");
|
||||
|
||||
|
||||
return cursor - string;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue