More fixes to access and buffer compilation.
This commit is contained in:
33
AST.jai
33
AST.jai
@@ -12,9 +12,7 @@ AST_Kind :: enum {
|
||||
// Directives
|
||||
If_Directive;
|
||||
|
||||
// Hint;
|
||||
// Type;
|
||||
// Operator;
|
||||
Access;
|
||||
Call;
|
||||
Struct;
|
||||
If;
|
||||
@@ -257,21 +255,35 @@ pretty_print_binary :: (node : *AST_Node, indentation : int, builder : *String_B
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
append(builder, "(");
|
||||
is_array_access := false;
|
||||
|
||||
if node.token.kind == .TOKEN_LEFTBRACKET {
|
||||
print_to_builder(builder, "[]");
|
||||
pretty_print_node(node.children[0], 0, builder);
|
||||
append(builder, "[");
|
||||
pretty_print_node(node.children[1], 0, builder);
|
||||
append(builder, "]");
|
||||
} else {
|
||||
append(builder, "(");
|
||||
op := node.token;
|
||||
print_to_builder(builder, op_to_string(op));
|
||||
append(builder, " ");
|
||||
|
||||
pretty_print_node(node.children[0], 0, builder);
|
||||
append(builder, " ");
|
||||
pretty_print_node(node.children[1], 0, builder);
|
||||
append(builder, ")");
|
||||
}
|
||||
|
||||
|
||||
append(builder, " ");
|
||||
}
|
||||
|
||||
pretty_print_access :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
if !skip_indent {
|
||||
indent(builder, indentation);
|
||||
}
|
||||
|
||||
pretty_print_node(node.children[0], 0, builder);
|
||||
append(builder, " ");
|
||||
append(builder, ".");
|
||||
pretty_print_node(node.children[1], 0, builder);
|
||||
append(builder, ")");
|
||||
}
|
||||
|
||||
pretty_print_unary :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
|
||||
@@ -402,6 +414,9 @@ pretty_print_node :: (node : *AST_Node, indentation : int, builder : *String_Bui
|
||||
case .Binary; {
|
||||
pretty_print_binary(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Access; {
|
||||
pretty_print_access(node, indentation, builder, skip_indent);
|
||||
}
|
||||
case .Unary; {
|
||||
pretty_print_unary(node, indentation, builder, skip_indent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user