diff options
| author | Carson Fleming <cflems@cflems.net> | 2026-07-21 14:36:02 -0700 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2026-07-21 14:36:02 -0700 |
| commit | 0cabbd2a0853c332c82af621b8716643741d758a (patch) | |
| tree | 4d1772e07ff1b81e00b563f877c6f1ead3305a8d /ast.h | |
| parent | f87e953223b7d498fc5401247952c08ab1e08f93 (diff) | |
| download | ccc-0cabbd2a0853c332c82af621b8716643741d758a.tar.gz | |
more faithful grammar
Diffstat (limited to 'ast.h')
| -rw-r--r-- | ast.h | 43 |
1 files changed, 21 insertions, 22 deletions
@@ -33,35 +33,23 @@ struct var_ref_node { struct var_decl_node { struct type_ref_node type; struct var_def* def_ref; -}; - -struct lval_node { - enum { - LVAL_VAR_DECL, - LVAL_VAR_REF, - } type; - union { - struct var_ref_node var_ref; - struct var_decl_node var_decl; - } inner; - - const struct type_def* resolved_type; + struct expr_node* initial_value; }; struct assign_node { - struct lval_node lval; + struct expr_node* lval; struct expr_node* rval; }; -struct args_eval_node { +struct expr_list_node { struct expr_node* expr; - struct args_eval_node* next; + struct expr_list_node* next; }; struct call_node { - /* TODO: eventually this could also be a function pointer */ + /* TODO: function pointers */ struct fn_decl_node* called_fn_ref; /* borrowed */ - struct args_eval_node* args; + struct expr_list_node* args; }; struct unary_node { @@ -114,15 +102,15 @@ struct group_node { struct scope* scope; }; -struct args_decl_node { +struct decl_list_node { struct var_decl_node* decl; - struct args_decl_node* next; + struct decl_list_node* next; }; struct fn_decl_node { struct type_ref_node return_type; char* name; - struct args_decl_node* args; + struct decl_list_node* args; struct group_node body; struct scope* scope; @@ -140,8 +128,19 @@ struct if_node { struct scope* scope; }; +struct loop_init_node { + enum { + INIT_EXPR_LIST, + INIT_DECL, + } type; + union { + struct expr_list_node* expr_list; + struct var_decl_node* decl; + }; +}; + struct loop_node { - struct expr_node* init; /* null if absent */ + struct loop_init_node* init; /* null if absent */ struct expr_node* cond; /* null if absent */ struct expr_node* incr; /* null if absent */ struct stmt_node* body; |
