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

24
AST.jai
View File

@@ -21,6 +21,7 @@ AST_Kind :: enum {
Call;
Struct;
If;
For;
CBuffer;
FieldList;
ArgList;
@@ -309,6 +310,26 @@ pretty_print_if :: (node : *AST_Node, indentation : int, builder : *String_Build
append(builder, ")");
}
pretty_print_for :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
if !skip_indent {
indent(builder, indentation);
}
append(builder, "(for ");
loop_iterator := node.token;
print_to_builder(builder, "% : ", loop_iterator.ident_value);
pretty_print_node(node.children[0], 0, builder);
append(builder, "..");
pretty_print_node(node.children[1], 0, builder);
append(builder, "\n");
pretty_print_node(node.children[2], indentation + 4, builder);
append(builder, ")");
}
print_expression_statement :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
if !skip_indent {
indent(builder, indentation);
@@ -327,6 +348,9 @@ pretty_print_node :: (node : *AST_Node, indentation : int, builder : *String_Bui
case .If; {
pretty_print_if(node, indentation, builder, skip_indent);
}
case .For; {
pretty_print_for(node, indentation, builder, skip_indent);
}
case .Struct;
case .ArgList; {
pretty_print_arglist(node, indentation + 2, builder, skip_indent);