#ifndef AST_H #define AST_H struct stmt_node; struct expr_node; struct type_node { char* type; }; struct var_decl_node { struct type_node type; char* ident; struct var_decl_node* next; }; struct group_node { struct stmt_node* body_head; }; struct fn_decl_node { struct type_node return_type; char* name; struct var_decl_node* args_head; struct group_node body; }; struct return_node { struct expr_node* ret_val; /* null to return void */ }; struct int_lit_node { long long val; }; struct expr_node { enum { EXPR_EMPTY, EXPR_INT_LIT, } type; union { struct int_lit_node _int_lit; } as; }; struct stmt_node { enum { STMT_EXPR, STMT_VAR_DECL, STMT_RETURN, STMT_GROUP, } type; union { struct expr_node _expr; struct var_decl_node _var_decl; struct return_node _return; struct group_node _group; } as; struct stmt_node* next; }; struct root_node { enum { ROOT_FN_DECL, } type; union { struct fn_decl_node _fn_decl; } as; struct root_node* next; }; void ast_destroy(struct root_node* head); #endif