From 190810fcb1144cd29a676e15dd8d1a414072862d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 29 Aug 2025 13:38:32 -0400 Subject: Add formatting for the last few cases --- src/formatter/formatter.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/formatter/formatter.c') 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)); -- cgit v1.2.3