summaryrefslogtreecommitdiff
path: root/parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y10
1 files changed, 10 insertions, 0 deletions
diff --git a/parser.y b/parser.y
index 2ec2264..cb1343f 100644
--- a/parser.y
+++ b/parser.y
@@ -16,6 +16,7 @@ void yyerror(const char *msg)
#define MKARGVALUE(v) (struct argument) { .type = ARG_INTEGER, .value = (v) }
#define MKARGLABEL(l) (struct argument) { .type = ARG_LABEL, .label = (l) }
#define MKARGTYPE(t) (struct argument) { .type = (t) }
+#define MKARGEXPR(op,c) (struct argument) { .type = (op), .children = c }
%}
@@ -84,6 +85,11 @@ void yyerror(const char *msg)
%token T_DOT "."
%token T_DEREF "@"
+%token T_OPERATOR_ADD "+"
+%token T_OPERATOR_SUB "-"
+%token T_OPERATOR_NOT "!"
+%token T_OPERATOR_INV "~"
+
%type <inst> inst
%type <arg> reg
%type <arg> regp
@@ -181,6 +187,10 @@ expr:
intlit { $$ = MKARGVALUE($1); }
| T_LABEL { $$ = MKARGLABEL($1); }
| "." { $$ = MKARGTYPE(ARG_PC); }
+ | "+" expr { $$ = MKARGEXPR(ARG_UNARY_ADD, { argdup(&$2) }); }
+ | "-" expr { $$ = MKARGEXPR(ARG_UNARY_SUB, { argdup(&$2) }); }
+ | "!" expr { $$ = MKARGEXPR(ARG_UNARY_NOT, { argdup(&$2) }); }
+ | "~" expr { $$ = MKARGEXPR(ARG_UNARY_INV, { argdup(&$2) }); }
;
intlit: T_INT