From fca3bf239cfdf03c4479f5d0c14a21c1fd96ea3e Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Fri, 27 Mar 2026 10:30:10 -1000 Subject: woah we got variables --- ast.h | 57 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 15 deletions(-) (limited to 'ast.h') diff --git a/ast.h b/ast.h index b058487..e5354ae 100644 --- a/ast.h +++ b/ast.h @@ -5,7 +5,19 @@ struct stmt_node; struct expr_node; struct type_node { - char* type; + bool _unsigned; + bool _short; + bool _long; + unsigned char ptr_level; + char* name; +}; + +struct int_lit_node { + long long val; +}; + +struct var_ref_node { + char* ident; }; struct var_decl_node { @@ -15,6 +27,35 @@ struct var_decl_node { struct var_decl_node* next; }; +struct lval_node { + enum { + LVAL_VAR_DECL, + LVAL_VAR_USE, + } type; + union { + struct var_ref_node _var_ref; + struct var_decl_node _var_decl; + } as; +}; + +/* TODO: add to expression, parse */ +struct assign_node { + struct lval_node lval; + struct expr_node* rval; +}; + +struct expr_node { + enum { + EXPR_EMPTY, + EXPR_INT_LIT, + EXPR_VAR_REF, + } type; + union { + struct int_lit_node _int_lit; + struct var_ref_node _var_ref; + } as; +}; + struct group_node { struct stmt_node* body_head; }; @@ -30,20 +71,6 @@ 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, -- cgit v1.2.3