Added basic for i loops. Missing some breaking tests and more tests. Also want to add for each at some point and it_index.

This commit is contained in:
2025-08-30 22:58:51 +02:00
parent 14f8b20d5f
commit 94fc3a4dad
7 changed files with 116 additions and 2 deletions

View File

@@ -494,6 +494,26 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
emit_node(state, node.children[0], 0);
append(*state.builder, ";");
}
case .For; {
if node.parent.kind != .For {
indent(*state.builder, indentation);
}
append(*state.builder, "for ");
loop_ident := node.token.ident_value;
begin_val := node.children[0].integer_value;
end_val := node.children[1].integer_value;
print_to_builder(*state.builder, "(int % = %; % < %; %++)\n", loop_ident, begin_val, loop_ident, end_val, loop_ident);
indent(*state.builder, indentation);
append(*state.builder, "{\n");
emit_block(state, node.children[2], indentation + 1);
indent(*state.builder, indentation);
append(*state.builder, "}\n");
}
case .If; {
if node.parent.kind != .If {
indent(*state.builder, indentation);