Files
bshell/bshell/ast/op.c
T

38 lines
782 B
C

#include "../operator.h"
#include "../parse/token.h"
#include "ast.h"
static enum bshell_status collect_children(
struct ast_node *node,
struct ast_iterator *it)
{
struct op_ast_node *op = (struct op_ast_node *)node;
if (op->n_left) {
ast_iterator_enqueue(it, op->n_left);
}
if (op->n_right) {
ast_iterator_enqueue(it, op->n_right);
}
return BSHELL_SUCCESS;
}
static void to_string(const struct ast_node *node, fx_bstr *out)
{
const struct op_ast_node *op = (const struct op_ast_node *)node;
fx_bstr_write_fmt(
out,
NULL,
"%s",
operator_id_to_string(op->n_op->op_id));
}
struct ast_node_definition op_ast_node = {
.def_id = AST_OP,
.def_node_size = sizeof(struct op_ast_node),
.def_collect_children = collect_children,
.def_to_string = to_string,
};