println and flatten are correct

This commit is contained in:
2026-03-01 13:59:33 +01:00
parent c1bc4db814
commit 24bfef4949
2 changed files with 7 additions and 4 deletions

2
ps3/src/.gdb_history Normal file
View File

@@ -0,0 +1,2 @@
l
exit

View File

@@ -224,11 +224,12 @@ static node_t* constant_fold_operator(node_t* node)
static node_t* simplify_println_statement(node_t* node)
{
assert(node->type == PRINTLN_STATEMENT);
node->type = PRINT_STATEMENT;
node_t *result = node_create(PRINT_STATEMENT, 1, node->children[0]);
node_t *newline = node_create(STRING_LITERAL, 0);
newline->data.string_literal = "\"\\n\"";
append_to_list_node(node, newline);
return node;
newline->data.string_literal = strdup("\"\\n\"");
append_to_list_node(node->children[0], newline);
node_finalize(node);
return result;
}
// Flatten all LOCAL_VARIABLE_DELCARATION nodes in the block, by converting them