#ifndef BDL_NODES_H #define BDL_NODES_H typedef enum NodeType { NODE_BUILTIN, NODE_NUMBER, NODE_BOOL, NODE_STRING, NODE_SYMBOL, NODE_TYPE, NODE_DEF, NODE_SET, NODE_FUN, NODE_BLOCK, NODE_IF, NODE_FUNCALL, } NodeType; typedef struct Node { size_t id; NodeType type; size_t line; size_t col; struct Type *expr_type; union { // Numbers. struct { bool negative; size_t integral; size_t fractional; } number; // String/symbol/type. StringView string; // Boolean. bool boolean; // Builtin primitive. struct { TokenType type; struct Node **args; } builtin; // Function call. struct { struct Node *name; struct Node **args; } funcall; // Variable definition. struct { struct Node *symbol; struct Node *value; struct Node *type; } def; // Variable assignment. struct { struct Node *symbol; struct Node *value; } set; // Function definition. struct { struct Node *name; struct Node **param_names; struct Node **param_types; struct Node *return_type; struct Node *body; } fun; // Block statements. struct { struct Node **expr; } block; // If statement. struct { struct Node *cond; struct Node *expr_true; struct Node *expr_false; } ifexpr; }; } Node; #endif // BDL_NODES_H