diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-29 13:38:32 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-29 13:38:32 -0400 |
| commit | 190810fcb1144cd29a676e15dd8d1a414072862d (patch) | |
| tree | 342bd65900732974452dc033942a9b494afdbcc7 /src | |
| parent | 43105107b9d1e985e9c182b904f2ac79b17fb460 (diff) | |
Add formatting for the last few cases
Diffstat (limited to 'src')
| -rw-r--r-- | src/formatter/formatter.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/formatter/formatter.c b/src/formatter/formatter.c index 2d88b486..89535071 100644 --- a/src/formatter/formatter.c +++ b/src/formatter/formatter.c @@ -352,6 +352,22 @@ OptionalText_t format_inline_code(ast_t *ast, Table_t comments) { Text_t space = op_tightness[ast->tag] >= op_tightness[Multiply] ? EMPTY_TEXT : Text(" "); return Texts(lhs, space, Text$from_str(binop_operator(ast->tag)), space, rhs); } + /*inline*/ case Deserialize: { + DeclareMatch(deserialize, ast, Deserialize); + return Texts("deserialize(", fmt_inline(deserialize->value, comments), " -> ", format_type(deserialize->type), + ")"); + } + /*inline*/ case Use: { + DeclareMatch(use, ast, Use); + // struct { + // ast_t *var; + // const char *path; + // enum { USE_LOCAL, USE_MODULE, USE_SHARED_OBJECT, USE_HEADER, USE_C_CODE, USE_ASM } what; + // } Use; + return Texts("use ", use->path); + } + /*inline*/ case ExplicitlyTyped: + fail("Explicitly typed AST nodes are only meant to be used internally."); default: { fail("Formatting not implemented for: ", ast_to_sexp(ast)); } @@ -749,6 +765,18 @@ Text_t format_code(ast_t *ast, Table_t comments, Text_t indent) { Text_t space = op_tightness[ast->tag] >= op_tightness[Multiply] ? EMPTY_TEXT : Text(" "); return Texts(lhs, space, Text$from_str(binop_operator(ast->tag)), space, rhs); } + /*multiline*/ case Deserialize: { + if (inlined_fits) return inlined; + DeclareMatch(deserialize, ast, Deserialize); + return Texts("deserialize(", fmt(deserialize->value, comments, indent), " -> ", format_type(deserialize->type), + ")"); + } + /*multiline*/ case Use: { + assert(inlined.length > 0); + return inlined; + } + /*multiline*/ case ExplicitlyTyped: + fail("Explicitly typed AST nodes are only meant to be used internally."); default: { if (inlined_fits) return inlined; fail("Formatting not implemented for: ", ast_to_sexp(ast)); |
