Added some initial directive code. Don't quite like the way it's done
This commit is contained in:
39
AST.jai
39
AST.jai
@@ -14,6 +14,8 @@ AST_Kind :: enum {
|
||||
Meta;
|
||||
Instance;
|
||||
//==
|
||||
// Directives
|
||||
If_Directive;
|
||||
|
||||
// Hint;
|
||||
// Type;
|
||||
@@ -191,7 +193,13 @@ pretty_print_children :: (parent : *AST_Node, indentation : int, builder : *Stri
|
||||
ind = 0;
|
||||
}
|
||||
// skip := ifx it_index > 0 then false else true;
|
||||
pretty_print_node(child, ind, builder);
|
||||
|
||||
if child.kind == .Function {
|
||||
pretty_print_declaration(child, ind, builder);
|
||||
} else {
|
||||
pretty_print_node(child, ind, builder);
|
||||
}
|
||||
|
||||
|
||||
if it_index != children.count - 1 {
|
||||
if flags & .Separator {
|
||||
@@ -434,6 +442,10 @@ pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder
|
||||
append(builder, "pixel ");
|
||||
}
|
||||
|
||||
if declaration.kind == .If_Directive {
|
||||
append(builder, "#if ");
|
||||
}
|
||||
|
||||
if declaration.kind == .Properties {
|
||||
append(builder, "properties");
|
||||
if declaration.name.count > 0 {
|
||||
@@ -463,24 +475,15 @@ pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder
|
||||
}
|
||||
|
||||
if declaration.children.count > 0 {
|
||||
// print_to_builder(builder, "\n");
|
||||
// if declaration.kind == .Function {
|
||||
// field_list := declaration.children[0];
|
||||
// pretty_print_fieldlist(field_list, indentation + 1, builder);
|
||||
// append(builder, "\n");
|
||||
if declaration.kind == .If_Directive {
|
||||
pretty_print_node(declaration.children[0], 0, builder);
|
||||
append(builder, "\n");
|
||||
pretty_print_node(declaration.children[1], indentation + 5, builder);
|
||||
} else {
|
||||
print_to_builder(builder, "\n");
|
||||
pretty_print_children(declaration, indentation + 1, builder, flags = .NewLine);
|
||||
}
|
||||
|
||||
// if declaration.children.count > 1 {
|
||||
// body := declaration.children[1];
|
||||
// pretty_print_node(body, indentation + 1, builder, true);
|
||||
// }
|
||||
// } else if declaration.kind == .Struct {
|
||||
// pretty_print_node(declaration.children[0], indentation + 1, builder);
|
||||
// } else {
|
||||
// pretty_print_node(declaration.children[0], indentation + 1, builder);
|
||||
// }
|
||||
|
||||
print_to_builder(builder, "\n");
|
||||
pretty_print_children(declaration, indentation + 1, builder, flags = .NewLine);
|
||||
}
|
||||
|
||||
append(builder, ")");
|
||||
|
||||
Reference in New Issue
Block a user