From 1dfa2971999b4adf36a33866b0b07af07188da08 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Tue, 31 Mar 2026 16:30:29 -1000 Subject: math n shi --- ast.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'ast.h') diff --git a/ast.h b/ast.h index 2eabb02..4837c2b 100644 --- a/ast.h +++ b/ast.h @@ -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; -- cgit v1.2.3