aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-03 15:01:23 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-03 15:01:23 -0400
commitcedae3039c8d67568b5ac35833c10cbfc1c7cb23 (patch)
tree1b1ff363a3c2be77d26acfb1a55dd267ec073f3e /src/ast.c
parent59993b85301071540a90a0e97df27e83000f77f7 (diff)
Fix textual representation of table types
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ast.c b/src/ast.c
index 75795d61..84d25db0 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -171,11 +171,21 @@ CORD ast_to_xml(ast_t *ast)
}
}
-const char *ast_to_str(ast_t *ast)
+const char *ast_to_xml_str(ast_t *ast)
{
return CORD_to_const_char_star(ast_to_xml(ast));
}
+const char *ast_source(ast_t *ast)
+{
+ if (!ast) return NULL;
+ size_t len = (size_t)(ast->end - ast->start);
+ char *source = GC_MALLOC_ATOMIC(len + 1);
+ memcpy(source, ast->start, len);
+ source[len] = '\0';
+ return source;
+}
+
CORD type_ast_to_xml(type_ast_t *t)
{
if (!t) return "NULL";