Add else parsing. Still a few bugs with output.

This commit is contained in:
2025-01-13 09:14:36 +01:00
parent 85b23f90e5
commit 4b927b6be9
4 changed files with 78 additions and 6 deletions

12
AST.jai
View File

@@ -228,9 +228,19 @@ print_return_node :: (node : *AST_Node, indentation : int, builder : *String_Bui
}
pretty_print_if :: (node : *AST_Node, indentation : int, builder : *String_Builder) {
indent(builder, indentation);
append(builder, "(if ");
pretty_print_children(node, 0, builder);
body := node.children[0];
pretty_print_node(body, 0, builder);
if node.children.count == 2 {
append(builder, "\n");
indent(builder, indentation);
append(builder, "(else ");
pretty_print_node(node.children[1], 0, builder);
append(builder, ")");
}
append(builder, ")");
}