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

37 lines
840 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>
2024-11-24 20:50:12 +00:00
#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_package_node *unit_package
= (struct ivy_ast_unit_package_node *)node;
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
2024-11-24 20:50:12 +00:00
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_package->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);
2024-11-24 20:50:12 +00:00
if (i > 0) {
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, ".");
2024-11-24 20:50:12 +00:00
}
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, tok->t_str);
i++;
2025-11-15 22:49:03 +00:00
2026-03-16 14:07:33 +00:00
entry = fx_queue_next(entry);
2024-11-24 20:50:12 +00:00
}
2026-03-16 14:07:33 +00:00
fx_string_append_cstr(str, ")");
}
struct ast_node_type unit_package_node_ops = {
.n_to_string = to_string,
.n_node_size = sizeof(struct ivy_ast_unit_package_node),
};