Files
ivy/lang/ast/unit-import.c
T

38 lines
835 B
C
Raw Normal View History

#include "node.h"
2026-03-16 14:07:33 +00:00
#include <fx/ds/string.h>
#include <ivy/lang/lex.h>
#include <stdio.h>
2026-03-16 14:07:33 +00:00
static void to_string(struct ivy_ast_node *node, fx_string *str)
{
struct ivy_ast_unit_import_node *unit_import
= (struct ivy_ast_unit_import_node *)node;
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, " (");
int i = 0;
2026-03-16 14:07:33 +00:00
fx_queue_entry *entry = fx_queue_first(&unit_import->n_ident);
2025-11-06 10:38:32 +00:00
while (entry) {
2026-03-16 14:07:33 +00:00
struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry);
if (i > 0) {
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, ".");
}
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, tok->t_str);
i++;
2026-03-16 14:07:33 +00:00
entry = fx_queue_next(entry);
}
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, ")");
}
struct ast_node_type unit_import_node_ops = {
.n_to_string = to_string,
.n_node_size = sizeof(struct ivy_ast_unit_import_node),
};