diff options
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; |
