parent
4d99e23946
commit
cb343cad5e
2 changed files with 28 additions and 9 deletions
|
|
@ -20,15 +20,6 @@ static inline void reusable_node_clear(ReusableNode *self) {
|
|||
self->last_external_token = NULL_SUBTREE;
|
||||
}
|
||||
|
||||
static inline void reusable_node_reset(ReusableNode *self, Subtree tree) {
|
||||
reusable_node_clear(self);
|
||||
array_push(&self->stack, ((StackEntry) {
|
||||
.tree = tree,
|
||||
.child_index = 0,
|
||||
.byte_offset = 0,
|
||||
}));
|
||||
}
|
||||
|
||||
static inline Subtree reusable_node_tree(ReusableNode *self) {
|
||||
return self->stack.size > 0
|
||||
? self->stack.contents[self->stack.size - 1].tree
|
||||
|
|
@ -86,3 +77,19 @@ static inline void reusable_node_advance_past_leaf(ReusableNode *self) {
|
|||
while (reusable_node_descend(self)) {}
|
||||
reusable_node_advance(self);
|
||||
}
|
||||
|
||||
static inline void reusable_node_reset(ReusableNode *self, Subtree tree) {
|
||||
reusable_node_clear(self);
|
||||
array_push(&self->stack, ((StackEntry) {
|
||||
.tree = tree,
|
||||
.child_index = 0,
|
||||
.byte_offset = 0,
|
||||
}));
|
||||
|
||||
// Never reuse the root node, because it has a non-standard internal structure
|
||||
// due to transformations that are applied when it is accepted: adding the EOF
|
||||
// child and any extra children.
|
||||
if (!reusable_node_descend(self)) {
|
||||
reusable_node_clear(self);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue