ast: implement to_string for int and double nodes

This commit is contained in:
2026-05-24 20:14:32 +01:00
parent fad13b5476
commit ca8533334b
2 changed files with 13 additions and 1 deletions
+10
View File
@@ -1,6 +1,16 @@
#include "../parse/token.h"
#include "ast.h"
#include <fx/stream.h>
static void to_string(const struct ast_node *node, fx_bstr *out)
{
struct double_ast_node *i = (struct double_ast_node *)node;
fx_value_to_string(&i->n_value->tok_number, (fx_stream *)out, NULL);
}
struct ast_node_definition double_ast_node = {
.def_id = AST_DOUBLE,
.def_node_size = sizeof(struct double_ast_node),
.def_to_string = to_string,
};
+3 -1
View File
@@ -1,10 +1,12 @@
#include "../parse/token.h"
#include "ast.h"
#include <fx/stream.h>
static void to_string(const struct ast_node *node, fx_bstr *out)
{
struct int_ast_node *i = (struct int_ast_node *)node;
fx_bstr_write_fmt(out, NULL, "%lld", i->n_value->tok_int);
fx_value_to_string(&i->n_value->tok_number, (fx_stream *)out, NULL);
}
struct ast_node_definition int_ast_node = {