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:
24
AST.jai
24
AST.jai
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user