summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/codegen/codegen.c15
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");