diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-25 12:12:02 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-25 12:12:02 -0400 |
| commit | 55479cbf9e4a8f36afe41d84df687f05fc7661f0 (patch) | |
| tree | 0bb00769f319716b75f5e0a3b0e73934de89aa88 /src/formatter.c | |
| parent | c3bcb504a07823ec8a096d34d0f4fe8dc5b27196 (diff) | |
Initial work to pass metadata for code
Diffstat (limited to 'src/formatter.c')
| -rw-r--r-- | src/formatter.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/formatter.c b/src/formatter.c new file mode 100644 index 00000000..81a5e126 --- /dev/null +++ b/src/formatter.c @@ -0,0 +1,23 @@ +// This code defines functions for transforming ASTs back into Tomo source text + +#include "ast.h" +#include "stdlib/datatypes.h" +#include "stdlib/optionals.h" +#include "stdlib/text.h" + +Text_t code_format(ast_t *ast, Table_t *comments) { + (void)comments; + switch (ast->tag) { + default: return Text$from_strn(ast->start, (int64_t)(ast->end - ast->start)); + } +} + +OptionalText_t code_format_inline(ast_t *ast, Table_t *comments) { + (void)comments; + for (const char *p = ast->start; p < ast->end; p++) { + if (*p == '\n' || *p == '\r') return NONE_TEXT; + } + switch (ast->tag) { + default: return Text$from_strn(ast->start, (int64_t)(ast->end - ast->start)); + } +} |
