summaryrefslogtreecommitdiff
path: root/ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h23
1 files changed, 22 insertions, 1 deletions
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;