diff options
| author | Carson Fleming <cflems@cflems.net> | 2026-03-31 16:30:29 -1000 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2026-03-31 16:30:29 -1000 |
| commit | 1dfa2971999b4adf36a33866b0b07af07188da08 (patch) | |
| tree | 7d65b9a5780a95bf519fed6d435bdade264aac62 /ast.h | |
| parent | 7cf2065be92855b5b1db31a4bb7afbb4af29a817 (diff) | |
| download | ccc-1dfa2971999b4adf36a33866b0b07af07188da08.tar.gz | |
math n shi
Diffstat (limited to 'ast.h')
| -rw-r--r-- | ast.h | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -52,7 +52,6 @@ struct lval_node { } as; }; -/* TODO: add to expression, parse */ struct assign_node { struct lval_node lval; struct expr_node* rval; @@ -64,6 +63,24 @@ struct call_node { struct expr_node* args_head; }; +struct unary_node { + enum { + UNARY_NEG, + } op; + struct expr_node* expr; +}; + +struct binary_node { + enum { + BINARY_ADD, + BINARY_SUB, + BINARY_MUL, + BINARY_DIV, + } op; + struct expr_node* lhs; + struct expr_node* rhs; +}; + struct expr_node { enum { EXPR_INT_LIT, @@ -73,6 +90,8 @@ struct expr_node { EXPR_VAR_REF, EXPR_ASSIGN, EXPR_CALL, + EXPR_UNARY, + EXPR_BINARY, } type; union { struct int_lit_node _int_lit; @@ -82,6 +101,8 @@ struct expr_node { struct var_ref_node _var_ref; struct assign_node _assign; struct call_node _call; + struct unary_node _unary; + struct binary_node _binary; } as; struct expr_node* next; |
