diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-27 17:26:51 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-27 17:26:51 -0400 |
| commit | 3c52a756339a2d96824d21a7d3ad5de7fc1085a0 (patch) | |
| tree | e5299a25ebb76186d6372b700710d7c8c7fe0728 /src/ast.c | |
| parent | 2186e84de0c0fd47ba48eaa35f74ea2754c3b81f (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.c | 19 |
1 files changed, 5 insertions, 14 deletions
@@ -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) { |
