diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-17 10:41:03 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-17 10:41:03 +0000 |
| commit | 42d955d21eb9a809bcdac6d7e8d27566b2b49da7 (patch) | |
| tree | 27e6b821e6b9b07fc717bc272a87e111faa8398b /src/codegen/codegen.c | |
| parent | 4c306516a6719fd32b515c573f9b8f9d04072129 (diff) | |
Improvement for prints inside 'match'.
Diffstat (limited to 'src/codegen/codegen.c')
| -rw-r--r-- | src/codegen/codegen.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/codegen/codegen.c b/src/codegen/codegen.c index 62f3126..9e85464 100644 --- a/src/codegen/codegen.c +++ b/src/codegen/codegen.c @@ -2073,6 +2073,21 @@ void codegen_node_single(ParserContext *ctx, ASTNode *node, FILE *out) fprintf(out, ";\n"); // Statement terminator break; } + case NODE_EXPR_LITERAL: + // String literal statement should auto-print + if (node->literal.type_kind == 2 || node->literal.type_kind == TOK_STRING) + { + fprintf(out, " printf(\"%%s\\n\", "); + codegen_expression(ctx, node, out); + fprintf(out, ");\n"); + } + else + { + // Non-string literals as statements - just evaluate + codegen_expression(ctx, node, out); + fprintf(out, ";\n"); + } + break; default: codegen_expression(ctx, node, out); fprintf(out, ";\n"); |
