Files

36 lines
889 B
C
Raw Permalink Normal View History

#include "ctx.h"
#include "iterate.h"
2025-11-06 10:38:32 +00:00
#include "node.h"
#include <blue/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str)
{
struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)node;
2025-11-06 10:38:32 +00:00
b_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
ivy_operator_id_to_string(op->n_op->op_id));
}
static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{
struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)node;
if (op->n_left) {
ast_node_iterator_enqueue_node(iterator, node, op->n_left);
}
if (op->n_right) {
ast_node_iterator_enqueue_node(iterator, node, op->n_right);
}
}
struct ast_node_type op_node_ops = {
.n_to_string = to_string,
.n_collect_children = collect_children,
.n_state_size = sizeof(struct parser_state),
.n_node_size = sizeof(struct ivy_ast_op_node),
};