summaryrefslogtreecommitdiff
path: root/ast.h
diff options
context:
space:
mode:
authorCarson Fleming <[email protected]>2026-03-27 10:30:10 -1000
committerCarson Fleming <[email protected]>2026-03-27 10:30:10 -1000
commitfca3bf239cfdf03c4479f5d0c14a21c1fd96ea3e (patch)
tree0618ad64a13e949ce9273098df724d8d25bdcb36 /ast.h
parent21f688c1eac5fb09ae68fd9b3cfcff687de36601 (diff)
downloadccc-fca3bf239cfdf03c4479f5d0c14a21c1fd96ea3e.tar.gz
woah we got variables
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h57
1 files changed, 42 insertions, 15 deletions
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,