lang: ast: replace ast node print callback with to_string
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
#include "ctx.h"
|
||||
#include "expr/expr.h"
|
||||
#include "node.h"
|
||||
#include <blue/object/string.h>
|
||||
|
||||
static void to_string(struct ivy_ast_node *node, b_string *str)
|
||||
{
|
||||
struct ivy_ast_string_node *s = (struct ivy_ast_string_node *)node;
|
||||
b_string_append_cstrf(str, "%s (\"%s\")", ivy_ast_node_type_to_string(node->n_type), s->n_value->t_str);
|
||||
}
|
||||
|
||||
struct token_parse_result parse_string(
|
||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
@@ -63,6 +70,7 @@ static void collect_children(
|
||||
}
|
||||
|
||||
struct ast_node_type string_node_ops = {
|
||||
.n_to_string = to_string,
|
||||
.n_state_size = sizeof(struct parser_state),
|
||||
.n_node_size = sizeof(struct ivy_ast_string_node),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user