about summary refs log tree commit diff
path: root/boot/tree.c
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-05-03 01:27:40 +0200
committerMel <mel@rnrd.eu>2026-05-03 01:27:40 +0200
commitfb13c2be5538b10ae456bcb30bfef6622ab6911f (patch)
tree87a69398ec9568b0240a14ed36e27379087fe301 /boot/tree.c
parent129e5669015a7ffd78d0f665f46cc434bcf126d2 (diff)
downloadcatskill-fb13c2be5538b10ae456bcb30bfef6622ab6911f.tar.zst
catskill-fb13c2be5538b10ae456bcb30bfef6622ab6911f.zip
Rename tree nodes to add consistent prefix, de-node, clean-up names
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/tree.c')
-rw-r--r--boot/tree.c526
1 files changed, 263 insertions, 263 deletions
diff --git a/boot/tree.c b/boot/tree.c
index 751cf02..07b96a3 100644
--- a/boot/tree.c
+++ b/boot/tree.c
@@ -398,26 +398,26 @@ increment_decrement_operation_to_string(enum Increment_Decrement_Operation opera
     }
 }
 
-// nodes are parts of the syntax tree that are reused often
-// and in different places.
+// these nodes outside of the expression/statement hierarchy are parts of
+// the syntax tree that are reused often and in different places.
 
 // a block of code, enclosed in curly braces.
 // represents a sequence of statements that are executed in order.
-struct Block_Node
+struct Tree_Block
 {
-    struct Statement* statements;
+    struct Tree_Statement* statements;
     struct Span span;
     struct Cursor location;
 };
 
 // a function header, describing the parameters and return type of function.
 // used both as a type and in full function definitions.
-struct Function_Header_Node
+struct Tree_Function_Header
 {
     // linked list of parameters.
     // name, if given, is included in the type node.
-    struct Type_Node* parameters_type_and_name;
-    struct Type_Node* return_type;
+    struct Tree_Type* parameters_type_and_name;
+    struct Tree_Type* return_type;
 
     struct Span span;
     struct Cursor location;
@@ -427,10 +427,10 @@ struct Function_Header_Node
 // constructions.
 // styled as either `1, 2, 3` or, when optional names
 // are given `a = 1, b = 2, c = 3`.
-struct Argument_Group_Node
+struct Tree_Argument_Group
 {
     // linked list of argument expressions.
-    struct Expression* arguments;
+    struct Tree_Expression* arguments;
     // names of the arguments, if given.
     // an unnamed argument is represented as an empty string.
     Array(struct String) argument_names;
@@ -440,101 +440,101 @@ struct Argument_Group_Node
 // signifier, like `let` or `var`.
 // the mutability is determined by some outside context, where
 // a bare declaration in a for-loop, for example, is always mutable.
-struct Bare_Declaration_Node
+struct Tree_Bare_Declaration
 {
     Array(struct String) names;
-    struct Expression* initializer;
-    struct Type_Node* type;
+    struct Tree_Expression* initializer;
+    struct Tree_Type* type;
 
     struct Span span;
     struct Cursor location;
 };
 
-enum Type_Node_Type
+enum Tree_Type_Type
 {
-    TYPE_NODE_NONE,
+    TREE_TYPE_NONE,
 
-    TYPE_NODE_NAME,
-    TYPE_NODE_ARRAY,     // an array of a type, `[int]`.
-    TYPE_NODE_REFERENCE, // a reference to a type, `&int`.
-    TYPE_NODE_MAYBE,     // a type that may be null, `int?`.
-    TYPE_NODE_TUPLE,     // a tuple type, `(int string)`.
-    TYPE_NODE_MAP,       // a map type, `[string = int]`.
+    TREE_TYPE_NAME,
+    TREE_TYPE_ARRAY,     // an array of a type, `[int]`.
+    TREE_TYPE_REFERENCE, // a reference to a type, `&int`.
+    TREE_TYPE_MAYBE,     // a type that may be null, `int?`.
+    TREE_TYPE_TUPLE,     // a tuple type, `(int string)`.
+    TREE_TYPE_MAP,       // a map type, `[string = int]`.
 
-    TYPE_NODE_FUNCTION,  // a function type, `fun (int) int`.
-    TYPE_NODE_STRUCTURE, // a struct, invoked either with `type` or with `{}` when a type is inline.
-    TYPE_NODE_VARIANT,   // a tagged union.
-    TYPE_NODE_CLASS,     // a class of types, a.k.a. an interface.
+    TREE_TYPE_FUNCTION,  // a function type, `fun (int) int`.
+    TREE_TYPE_STRUCTURE, // a struct, invoked either with `type` or with `{}` when a type is inline.
+    TREE_TYPE_VARIANT,   // a tagged union.
+    TREE_TYPE_CLASS,     // a class of types, a.k.a. an interface.
 };
 
-struct Type_Node_Name
+struct Tree_Type_Name
 {
     struct String name;
 };
 
-struct Type_Node_Array
+struct Tree_Type_Array
 {
-    struct Type_Node* element_type;
+    struct Tree_Type* element_type;
 };
 
-struct Type_Node_Reference
+struct Tree_Type_Reference
 {
-    struct Type_Node* referenced_type;
+    struct Tree_Type* referenced_type;
 };
 
-struct Type_Node_Maybe
+struct Tree_Type_Maybe
 {
-    struct Type_Node* inner_type;
+    struct Tree_Type* inner_type;
 };
 
-struct Type_Node_Tuple
+struct Tree_Type_Tuple
 {
-    struct Type_Node* head; // the first type in the tuple, if any.
+    struct Tree_Type* head; // the first type in the tuple, if any.
 };
 
-struct Type_Node_Map
+struct Tree_Type_Map
 {
-    struct Type_Node* key_type;
-    struct Type_Node* value_type;
+    struct Tree_Type* key_type;
+    struct Tree_Type* value_type;
 };
 
-struct Type_Node_Function
+struct Tree_Type_Function
 {
-    struct Function_Header_Node header;
+    struct Tree_Function_Header header;
 };
 
-struct Type_Node_Structure
+struct Tree_Type_Structure
 {
     // the fields of the structure, linked list of types and (required) names.
-    struct Type_Node* fields;
+    struct Tree_Type* fields;
 };
 
-struct Type_Node_Variant
+struct Tree_Type_Variant
 {
     // the variants of the tagged union, linked list of (required) variant names and backing types.
-    // if a variant has no backing type, it is TYPE_NODE_NONE.
-    struct Type_Node* variants;
+    // if a variant has no backing type, it is TREE_TYPE_NONE.
+    struct Tree_Type* variants;
 };
 
-struct Type_Node_Class
+struct Tree_Type_Class
 {
     // linked list of the types of methods required to implement the class.
-    // each node is required to have a name and be of TYPE_NODE_FUNCTION.
-    struct Type_Node* methods;
+    // each node is required to have a name and be of TREE_TYPE_FUNCTION.
+    struct Tree_Type* methods;
 };
 
-union Type_Node_Value
-{
-    struct Type_Node_Name name;
-    struct Type_Node_Array array;
-    struct Type_Node_Reference reference;
-    struct Type_Node_Maybe maybe;
-    struct Type_Node_Tuple tuple;
-    struct Type_Node_Map map;
-    struct Type_Node_Function function;
-    struct Type_Node_Structure structure;
-    struct Type_Node_Variant variant;
-    struct Type_Node_Class class;
+union Tree_Type_Value
+{
+    struct Tree_Type_Name name;
+    struct Tree_Type_Array array;
+    struct Tree_Type_Reference reference;
+    struct Tree_Type_Maybe maybe;
+    struct Tree_Type_Tuple tuple;
+    struct Tree_Type_Map map;
+    struct Tree_Type_Function function;
+    struct Tree_Type_Structure structure;
+    struct Tree_Type_Variant variant;
+    struct Tree_Type_Class class;
 };
 
 // a type node represents a type in the syntax tree.
@@ -542,10 +542,10 @@ union Type_Node_Value
 // or null types.
 // also includes the name of the field, member, parameter, etc., for which
 // the type is defined.
-struct Type_Node
+struct Tree_Type
 {
-    enum Type_Node_Type type;
-    union Type_Node_Value value;
+    enum Tree_Type_Type type;
+    union Tree_Type_Value value;
     // note: we could also just include the token here i think?
     struct Span span;
     struct Cursor location;
@@ -560,19 +560,19 @@ struct Type_Node
 
     // if type is within a group of multiple types,
     // points to the next type within the group.
-    struct Type_Node* next;
+    struct Tree_Type* next;
 };
 
-REGION(struct Type_Node, type_node)
+REGION(struct Tree_Type, tree_type)
 
 // allocates a new type node in the global type node region.
-struct Type_Node*
-type_node_new(
-    enum Type_Node_Type type, union Type_Node_Value value, struct Span span, struct Cursor location)
+struct Tree_Type*
+tree_type_new(
+    enum Tree_Type_Type type, union Tree_Type_Value value, struct Span span, struct Cursor location)
 {
-    check(region_type_node_cursor < REGION_SIZE, "out of type node memory");
-    struct Type_Node* type_node = &region_type_node[region_type_node_cursor++];
-    *type_node = (struct Type_Node){
+    check(region_tree_type_cursor < REGION_SIZE, "out of type node memory");
+    struct Tree_Type* tree_type = &region_tree_type[region_tree_type_cursor++];
+    *tree_type = (struct Tree_Type){
         .type = type,
         .value = value,
         .span = span,
@@ -581,29 +581,29 @@ type_node_new(
         .value_name = string_empty(),
         .next = nil,
     };
-    return type_node;
+    return tree_type;
 }
 
 // allocates a new type node with no value, used for `none` types.
 // this is used for types that are not specified, note that it is still
 // fully allocated and can be used in the syntax tree.
-struct Type_Node*
-type_node_none(struct Span span, struct Cursor location)
+struct Tree_Type*
+tree_type_none(struct Span span, struct Cursor location)
 {
-    return type_node_new(TYPE_NODE_NONE, (union Type_Node_Value){ 0 }, span, location);
+    return tree_type_new(TREE_TYPE_NONE, (union Tree_Type_Value){ 0 }, span, location);
 }
 
 bool
-type_node_is_none(const struct Type_Node* type_node)
+tree_type_is_none(const struct Tree_Type* tree_type)
 {
-    return type_node->type == TYPE_NODE_NONE;
+    return tree_type->type == TREE_TYPE_NONE;
 }
 
-enum Pragma_Type
+enum Tree_Pragma_Type
 {
-    PRAGMA_NONE,
-    PRAGMA_UNKNOWN,
-    PRAGMA_C_HEADER,
+    TREE_PRAGMA_NONE,
+    TREE_PRAGMA_UNKNOWN,
+    TREE_PRAGMA_C_HEADER,
     // TODO: further pragma types.
 
     // NOTE: there would be plenty of use for user-defined pragmas,
@@ -612,19 +612,19 @@ enum Pragma_Type
     // but it's something to definitely consider in the future.
 };
 
-#define PRAGMA_ARGUMENT_MAX 3
+#define TREE_PRAGMA_ARGUMENT_MAX 3
 
-struct Pragma_Argument
+struct Tree_Pragma_Argument
 {
-    enum Pragma_Argument_Type
+    enum Tree_Pragma_Argument_Type
     {
-        PRAGMA_ARGUMENT_NONE,
-        PRAGMA_ARGUMENT_NAME_OR_STRING,
-        PRAGMA_ARGUMENT_NUMBER,
-        PRAGMA_ARGUMENT_DECIMAL,
+        TREE_PRAGMA_ARGUMENT_NONE,
+        TREE_PRAGMA_ARGUMENT_NAME_OR_STRING,
+        TREE_PRAGMA_ARGUMENT_NUMBER,
+        TREE_PRAGMA_ARGUMENT_DECIMAL,
     } type;
 
-    union Pragma_Argument_Value
+    union Tree_Pragma_Argument_Value
     {
         struct String name_or_string;
         int64 number;
@@ -639,26 +639,26 @@ struct Pragma_Argument
 // behaviour, to including different C compilation units and other catskill modules.
 // pragmas are parsed as lone statements in the source code at first, but are then
 // "attached" to the relevant nodes of the type the pragma is relevant to.
-struct Pragma_Node
+struct Tree_Pragma
 {
-    enum Pragma_Type type;
-    struct Pragma_Argument arguments[PRAGMA_ARGUMENT_MAX];
+    enum Tree_Pragma_Type type;
+    struct Tree_Pragma_Argument arguments[TREE_PRAGMA_ARGUMENT_MAX];
     uint argument_count;
 
     struct Span span;
     struct Cursor location;
 
-    struct Pragma_Node* next; // further pragmas on the same line.
+    struct Tree_Pragma* next; // further pragmas on the same line.
 };
 
-REGION(struct Pragma_Node, pragma_node)
+REGION(struct Tree_Pragma, tree_pragma)
 
-struct Pragma_Node*
-pragma_node_new(enum Pragma_Type type, struct Span span, struct Cursor location)
+struct Tree_Pragma*
+tree_pragma_new(enum Tree_Pragma_Type type, struct Span span, struct Cursor location)
 {
-    check(region_pragma_node_cursor < REGION_SIZE, "out of pragma node memory");
-    struct Pragma_Node* pragma = &region_pragma_node[region_pragma_node_cursor++];
-    *pragma = (struct Pragma_Node){
+    check(region_tree_pragma_cursor < REGION_SIZE, "out of pragma node memory");
+    struct Tree_Pragma* pragma = &region_tree_pragma[region_tree_pragma_cursor++];
+    *pragma = (struct Tree_Pragma){
         .type = type,
         .arguments = {},
         .argument_count = 0,
@@ -669,202 +669,202 @@ pragma_node_new(enum Pragma_Type type, struct Span span, struct Cursor location)
     return pragma;
 }
 
-enum Pragma_Type
-pragma_type_from_string(struct String name)
+enum Tree_Pragma_Type
+tree_pragma_type_from_string(struct String name)
 {
     // look up hash values with:
     // `echo -ne "string to hash" | cksum`
     uint32 hash = crc32_posix(name);
     switch (hash) {
     case 2852954401: // "c_header"
-        return PRAGMA_C_HEADER;
+        return TREE_PRAGMA_C_HEADER;
     default:
-        return PRAGMA_UNKNOWN;
+        return TREE_PRAGMA_UNKNOWN;
     }
 }
 
 const ascii*
-pragma_type_to_string(enum Pragma_Type type)
+tree_pragma_type_to_string(enum Tree_Pragma_Type type)
 {
     switch (type) {
-    case PRAGMA_C_HEADER:
+    case TREE_PRAGMA_C_HEADER:
         return "c_header";
-    case PRAGMA_UNKNOWN:
+    case TREE_PRAGMA_UNKNOWN:
         return "unknown";
     default:
-        failure("unexpected pragma type passed to `pragma_type_to_string`");
+        failure("unexpected pragma type passed to `tree_pragma_type_to_string`");
         return nil;
     }
 }
 
-enum Expression_Kind
+enum Tree_Expression_Kind
 {
-    EXPRESSION_NONE,
+    TREE_EXPRESSION_NONE,
 
-    EXPRESSION_INTEGER_LITERAL,
-    EXPRESSION_FLOAT_LITERAL,
-    EXPRESSION_STRING_LITERAL,
-    EXPRESSION_BOOLEAN_LITERAL,
-    EXPRESSION_NAME,
+    TREE_EXPRESSION_INTEGER_LITERAL,
+    TREE_EXPRESSION_FLOAT_LITERAL,
+    TREE_EXPRESSION_STRING_LITERAL,
+    TREE_EXPRESSION_BOOLEAN_LITERAL,
+    TREE_EXPRESSION_NAME,
 
-    EXPRESSION_UNARY_OPERATION,
-    EXPRESSION_BINARY_OPERATION,
+    TREE_EXPRESSION_UNARY_OPERATION,
+    TREE_EXPRESSION_BINARY_OPERATION,
 
-    EXPRESSION_GROUP,
-    EXPRESSION_CONSTRUCT,
-    EXPRESSION_CALL,
-    EXPRESSION_SUBSCRIPT,
-    EXPRESSION_MEMBER,
-    EXPRESSION_INCREMENT_DECREMENT,
-    EXPRESSION_TRY,
-    EXPRESSION_MUST,
+    TREE_EXPRESSION_GROUP,
+    TREE_EXPRESSION_CONSTRUCT,
+    TREE_EXPRESSION_CALL,
+    TREE_EXPRESSION_SUBSCRIPT,
+    TREE_EXPRESSION_MEMBER,
+    TREE_EXPRESSION_INCREMENT_DECREMENT,
+    TREE_EXPRESSION_TRY,
+    TREE_EXPRESSION_MUST,
 
-    EXPRESSION_FUNCTION,
-    EXPRESSION_TYPE,
+    TREE_EXPRESSION_FUNCTION,
+    TREE_EXPRESSION_TYPE,
 };
 
-struct Expression_Integer_Literal
+struct Tree_Expression_Integer_Literal
 {
     int64 value; // might not fit entire number given in source.
 };
 
-struct Expression_Float_Literal
+struct Tree_Expression_Float_Literal
 {
     float64 value;
 };
 
-struct Expression_String_Literal
+struct Tree_Expression_String_Literal
 {
     struct String value;
 };
 
-struct Expression_Bool_Literal
+struct Tree_Expression_Bool_Literal
 {
     bool value;
 };
 
-struct Expression_Name
+struct Tree_Expression_Name
 {
     struct String name;
 };
 
-struct Expression_Unary_Operator
+struct Tree_Expression_Unary_Operator
 {
     enum Unary_Operation operation;
-    struct Expression* operand;
+    struct Tree_Expression* operand;
 };
 
-struct Expression_Binary_Operator
+struct Tree_Expression_Binary_Operator
 {
     enum Binary_Operation operation;
-    struct Expression* left_operand;
-    struct Expression* right_operand;
+    struct Tree_Expression* left_operand;
+    struct Tree_Expression* right_operand;
 };
 
-struct Expression_Group
+struct Tree_Expression_Group
 {
-    struct Expression* inner_expression;
+    struct Tree_Expression* inner_expression;
 };
 
-struct Expression_Call
+struct Tree_Expression_Call
 {
-    struct Expression* subject;
-    struct Argument_Group_Node argument_group;
+    struct Tree_Expression* subject;
+    struct Tree_Argument_Group argument_group;
 };
 
-struct Expression_Construct
+struct Tree_Expression_Construct
 {
     // this should be the type to construct, e.g. `int` or `string` or a generic like `Maybe(X)`
     // right now, we can't guarantee it fully.
-    struct Expression* subject;
-    struct Argument_Group_Node argument_group;
+    struct Tree_Expression* subject;
+    struct Tree_Argument_Group argument_group;
 };
 
-struct Expression_Subscript
+struct Tree_Expression_Subscript
 {
-    struct Expression* subject;
-    struct Expression* index;
+    struct Tree_Expression* subject;
+    struct Tree_Expression* index;
 };
 
-struct Expression_Member
+struct Tree_Expression_Member
 {
-    struct Expression* subject;
+    struct Tree_Expression* subject;
     struct String name;
 };
 
-struct Expression_Increment_Decrement
+struct Tree_Expression_Increment_Decrement
 {
     // whether the increment/decrement is a prefix or postfix operation.
     bool prefix;
-    struct Expression* subject;
+    struct Tree_Expression* subject;
     enum Increment_Decrement_Operation operation;
 };
 
-struct Expression_Try
+struct Tree_Expression_Try
 {
-    struct Expression* expression;
+    struct Tree_Expression* expression;
 };
 
-struct Expression_Must
+struct Tree_Expression_Must
 {
-    struct Expression* expression;
+    struct Tree_Expression* expression;
 };
 
-struct Expression_Function
+struct Tree_Expression_Function
 {
-    struct Function_Header_Node header;
-    struct Block_Node body;
+    struct Tree_Function_Header header;
+    struct Tree_Block body;
 };
 
-struct Expression_Type
+struct Tree_Expression_Type
 {
-    struct Type_Node* type;
+    struct Tree_Type* type;
 };
 
-union Expression_Value
-{
-    struct Expression_Integer_Literal integer_literal;
-    struct Expression_Float_Literal float_literal;
-    struct Expression_String_Literal string_literal;
-    struct Expression_Bool_Literal bool_literal;
-    struct Expression_Name name;
-    struct Expression_Unary_Operator unary_operator;
-    struct Expression_Binary_Operator binary_operator;
-    struct Expression_Group group;
-    struct Expression_Call call;
-    struct Expression_Construct construct;
-    struct Expression_Subscript subscript;
-    struct Expression_Member member;
-    struct Expression_Increment_Decrement increment_decrement;
-    struct Expression_Try try;
-    struct Expression_Must must;
-    struct Expression_Function function;
-    struct Expression_Type type;
+union Tree_Expression_Value
+{
+    struct Tree_Expression_Integer_Literal integer_literal;
+    struct Tree_Expression_Float_Literal float_literal;
+    struct Tree_Expression_String_Literal string_literal;
+    struct Tree_Expression_Bool_Literal bool_literal;
+    struct Tree_Expression_Name name;
+    struct Tree_Expression_Unary_Operator unary_operator;
+    struct Tree_Expression_Binary_Operator binary_operator;
+    struct Tree_Expression_Group group;
+    struct Tree_Expression_Call call;
+    struct Tree_Expression_Construct construct;
+    struct Tree_Expression_Subscript subscript;
+    struct Tree_Expression_Member member;
+    struct Tree_Expression_Increment_Decrement increment_decrement;
+    struct Tree_Expression_Try try;
+    struct Tree_Expression_Must must;
+    struct Tree_Expression_Function function;
+    struct Tree_Expression_Type type;
 };
 
-struct Expression
+struct Tree_Expression
 {
-    enum Expression_Kind kind;
-    union Expression_Value value;
+    enum Tree_Expression_Kind kind;
+    union Tree_Expression_Value value;
 
     struct Span span;
     struct Cursor location;
 
     // if expression is within a group of multiple expressions,
     // points to the next expression within it.
-    struct Expression* next;
+    struct Tree_Expression* next;
 };
 
-REGION(struct Expression, expression)
+REGION(struct Tree_Expression, tree_expression)
 
-struct Expression*
-expression_new(
-    enum Expression_Kind kind, union Expression_Value value, struct Span span,
+struct Tree_Expression*
+tree_expression_new(
+    enum Tree_Expression_Kind kind, union Tree_Expression_Value value, struct Span span,
     struct Cursor location)
 {
-    check(region_expression_cursor < REGION_SIZE, "out of expression memory");
-    struct Expression* expression = &region_expression[region_expression_cursor++];
-    *expression = (struct Expression){
+    check(region_tree_expression_cursor < REGION_SIZE, "out of expression memory");
+    struct Tree_Expression* expression = &region_tree_expression[region_tree_expression_cursor++];
+    *expression = (struct Tree_Expression){
         .kind = kind,
         .value = value,
         .span = span,
@@ -874,146 +874,146 @@ expression_new(
     return expression;
 }
 
-enum Statement_Kind
+enum Tree_Statement_Kind
 {
-    STATEMENT_NONE,
-    STATEMENT_EXPRESSION,
-    STATEMENT_DECLARATION,
+    TREE_STATEMENT_NONE,
+    TREE_STATEMENT_EXPRESSION,
+    TREE_STATEMENT_DECLARATION,
     // NOTE: a block could be an expression in the future.
-    STATEMENT_BLOCK,
-    STATEMENT_CONDITIONAL,
-    STATEMENT_LOOP,
-    STATEMENT_RETURN,
-    STATEMENT_BREAK,
-    STATEMENT_CONTINUE,
-    STATEMENT_DEFER,
-
-    STATEMENT_PRAGMA,
+    TREE_STATEMENT_BLOCK,
+    TREE_STATEMENT_CONDITIONAL,
+    TREE_STATEMENT_LOOP,
+    TREE_STATEMENT_RETURN,
+    TREE_STATEMENT_BREAK,
+    TREE_STATEMENT_CONTINUE,
+    TREE_STATEMENT_DEFER,
+
+    TREE_STATEMENT_PRAGMA,
 };
 
-struct Statement_Value_Expression
+struct Tree_Statement_Value_Expression
 {
-    struct Expression* inner;
+    struct Tree_Expression* inner;
 };
 
-enum Statement_Declaration_Kind
+enum Tree_Statement_Declaration_Kind
 {
-    STATEMENT_DECLARATION_NONE,
-    STATEMENT_DECLARATION_VARIABLE,
-    STATEMENT_DECLARATION_CONSTANT,
+    TREE_STATEMENT_DECLARATION_NONE,
+    TREE_STATEMENT_DECLARATION_VARIABLE,
+    TREE_STATEMENT_DECLARATION_CONSTANT,
 };
 
-enum Statement_Declaration_Kind
-statement_declaration_kind_from_token(const struct Token* token)
+enum Tree_Statement_Declaration_Kind
+tree_statement_declaration_kind_from_token(const struct Token* token)
 {
     switch (token->kind) {
     case TOKEN_WORD_VAR:
-        return STATEMENT_DECLARATION_VARIABLE;
+        return TREE_STATEMENT_DECLARATION_VARIABLE;
     case TOKEN_WORD_LET:
-        return STATEMENT_DECLARATION_CONSTANT;
+        return TREE_STATEMENT_DECLARATION_CONSTANT;
 
     default:
-        return STATEMENT_DECLARATION_NONE;
+        return TREE_STATEMENT_DECLARATION_NONE;
     }
 }
 
-struct Statement_Value_Declaration
+struct Tree_Statement_Value_Declaration
 {
-    enum Statement_Declaration_Kind kind;
-    struct Bare_Declaration_Node inner;
+    enum Tree_Statement_Declaration_Kind kind;
+    struct Tree_Bare_Declaration inner;
 };
 
-struct Statement_Value_Block
+struct Tree_Statement_Value_Block
 {
-    struct Block_Node inner; // the block of statements.
+    struct Tree_Block inner; // the block of statements.
 };
 
-#define STATEMENT_VALUE_CONDITIONAL_MAX 8
+#define TREE_STATEMENT_VALUE_CONDITIONAL_MAX 8
 
-struct Statement_Value_Conditional
+struct Tree_Statement_Value_Conditional
 {
-    struct Statement_Conditional_Branch
+    struct Tree_Statement_Conditional_Branch
     {
         // if nil, the condition is always true.
-        struct Expression* when;
-        struct Block_Node then;
-    } conditions[STATEMENT_VALUE_CONDITIONAL_MAX];
+        struct Tree_Expression* when;
+        struct Tree_Block then;
+    } conditions[TREE_STATEMENT_VALUE_CONDITIONAL_MAX];
     uint condition_count;
 };
 
-enum Statement_Loop_Style
+enum Tree_Statement_Loop_Style
 {
-    STATEMENT_LOOP_STYLE_NONE,
-    STATEMENT_LOOP_STYLE_C,        // for i int = 0; i < 10; ++i {}
-    STATEMENT_LOOP_STYLE_FOR_EACH, // for x Obj = list {}
-    STATEMENT_LOOP_STYLE_WHILE,    // while true {}
-    STATEMENT_LOOP_STYLE_ENDLESS,  // while {}
+    TREE_STATEMENT_LOOP_STYLE_NONE,
+    TREE_STATEMENT_LOOP_STYLE_C,        // for i int = 0; i < 10; ++i {}
+    TREE_STATEMENT_LOOP_STYLE_FOR_EACH, // for x Obj = list {}
+    TREE_STATEMENT_LOOP_STYLE_WHILE,    // while true {}
+    TREE_STATEMENT_LOOP_STYLE_ENDLESS,  // while {}
 };
 
 // stands for both `for` and `while` loops.
-struct Statement_Value_Loop
+struct Tree_Statement_Value_Loop
 {
-    enum Statement_Loop_Style style;
-    struct Bare_Declaration_Node declaration;
-    struct Expression* condition;
-    struct Expression* iteration;
+    enum Tree_Statement_Loop_Style style;
+    struct Tree_Bare_Declaration declaration;
+    struct Tree_Expression* condition;
+    struct Tree_Expression* iteration;
 
-    struct Block_Node body;
+    struct Tree_Block body;
 };
 
-struct Statement_Value_Return
+struct Tree_Statement_Value_Return
 {
     // nil if there is no return value.
-    struct Expression* value;
+    struct Tree_Expression* value;
 };
 
-struct Statement_Value_Defer
+struct Tree_Statement_Value_Defer
 {
     // either a simple expression, or, if expression is nil,
     // a block of code to execute.
-    struct Expression* expression;
-    struct Block_Node block;
+    struct Tree_Expression* expression;
+    struct Tree_Block block;
 };
 
-struct Statement_Value_Pragma
+struct Tree_Statement_Value_Pragma
 {
-    struct Pragma_Node* inner;
+    struct Tree_Pragma* inner;
 };
 
-union Statement_Value
+union Tree_Statement_Value
 {
-    struct Statement_Value_Expression expression;
-    struct Statement_Value_Declaration declaration;
-    struct Statement_Value_Block block;
-    struct Statement_Value_Conditional conditional;
-    struct Statement_Value_Loop loop;
-    struct Statement_Value_Return return_value;
-    struct Statement_Value_Defer defer;
-    struct Statement_Value_Pragma pragma;
+    struct Tree_Statement_Value_Expression expression;
+    struct Tree_Statement_Value_Declaration declaration;
+    struct Tree_Statement_Value_Block block;
+    struct Tree_Statement_Value_Conditional conditional;
+    struct Tree_Statement_Value_Loop loop;
+    struct Tree_Statement_Value_Return return_value;
+    struct Tree_Statement_Value_Defer defer;
+    struct Tree_Statement_Value_Pragma pragma;
 };
 
-struct Statement
+struct Tree_Statement
 {
-    enum Statement_Kind kind;
-    union Statement_Value value;
+    enum Tree_Statement_Kind kind;
+    union Tree_Statement_Value value;
 
     struct Span span;
     struct Cursor location;
 
     // if statement is within a group of multiple statements,
     // points to the next statement within it.
-    struct Statement* next;
+    struct Tree_Statement* next;
 };
 
-REGION(struct Statement, statement)
+REGION(struct Tree_Statement, tree_statement)
 
-struct Statement*
-statement_new(
-    enum Statement_Kind kind, union Statement_Value value, struct Span span, struct Cursor location)
+struct Tree_Statement*
+tree_statement_new(
+    enum Tree_Statement_Kind kind, union Tree_Statement_Value value, struct Span span, struct Cursor location)
 {
-    check(region_statement_cursor < REGION_SIZE, "out of statement memory");
-    struct Statement* statement = &region_statement[region_statement_cursor++];
-    *statement = (struct Statement){
+    check(region_tree_statement_cursor < REGION_SIZE, "out of statement memory");
+    struct Tree_Statement* statement = &region_tree_statement[region_tree_statement_cursor++];
+    *statement = (struct Tree_Statement){
         .kind = kind,
         .value = value,
         .span = span,
@@ -1026,5 +1026,5 @@ statement_new(
 // the top-level tree of a single catskill source file.
 struct Tree
 {
-    struct Statement* top_level_statements;
+    struct Tree_Statement* top_level_statements;
 };