aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-27 17:26:51 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-27 17:26:51 -0400
commit3c52a756339a2d96824d21a7d3ad5de7fc1085a0 (patch)
treee5299a25ebb76186d6372b700710d7c8c7fe0728 /src/ast.c
parent2186e84de0c0fd47ba48eaa35f74ea2754c3b81f (diff)
Deprecate custom printf specifiers in favor of print() function that
uses _Generic() to generically convert any value to a string or print as a string.
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/ast.c b/src/ast.c
index 9f1bc42b..d04fa437 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -1,7 +1,6 @@
// Some basic operations defined on AST nodes, mainly converting to
// strings for debugging.
#include <gc/cord.h>
-#include <printf.h>
#include <stdarg.h>
#include "ast.h"
@@ -174,6 +173,11 @@ CORD ast_to_xml(ast_t *ast)
}
}
+const char *ast_to_str(ast_t *ast)
+{
+ return CORD_to_const_char_star(ast_to_xml(ast));
+}
+
CORD type_ast_to_xml(type_ast_t *t)
{
if (!t) return "NULL";
@@ -195,19 +199,6 @@ CORD type_ast_to_xml(type_ast_t *t)
}
}
-int printf_ast(FILE *stream, const struct printf_info *info, const void *const args[])
-{
- ast_t *ast = *(ast_t**)(args[0]);
- if (ast) {
- if (info->alt)
- return fprintf(stream, "%.*s", (int)(ast->end - ast->start), ast->start);
- else
- return CORD_put(ast_to_xml(ast), stream);
- } else {
- return fputs("(null)", stream);
- }
-}
-
PUREFUNC bool is_idempotent(ast_t *ast)
{
switch (ast->tag) {