33 lines
843 B
C
33 lines
843 B
C
#include "ctx.h"
|
|
#include "node.h"
|
|
#include "iterate.h"
|
|
#include <stdio.h>
|
|
|
|
static void print(struct ivy_ast_node *node)
|
|
{
|
|
struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)node;
|
|
|
|
printf("%s (%s)\n", 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_print = print,
|
|
.n_collect_children = collect_children,
|
|
.n_state_size = sizeof(struct parser_state),
|
|
.n_node_size = sizeof(struct ivy_ast_op_node),
|
|
};
|