summaryrefslogtreecommitdiff
path: root/parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y36
1 files changed, 27 insertions, 9 deletions
diff --git a/parser.y b/parser.y
index e6cb0b1..f63a70f 100644
--- a/parser.y
+++ b/parser.y
@@ -78,13 +78,13 @@ void yyerror(const char *msg)
%token <lval> T_INT
%token T_BADINT
-%token <arg> T_REG
-%token <arg> T_REGPTR
-
%token T_COMMA ","
%token T_COLON ":"
+%token T_DEREF "@"
%type <inst> inst
+%type <arg> reg
+%type <arg> regp
%type <arg> expr
%type <args> a_reg2
%type <args> a_reg3
@@ -150,20 +150,38 @@ inst:
;
a_reg2:
- T_SPACE T_REG "," T_REG { $$ = MKARGS($2, $4); }
+ T_SPACE reg "," reg { $$ = MKARGS($2, $4); }
a_reg3:
- T_SPACE T_REG "," T_REG "," T_REG { $$ = MKARGS($2, $4, $6); }
+ T_SPACE reg "," reg "," reg { $$ = MKARGS($2, $4, $6); }
a_regp:
- T_SPACE T_REGPTR { $$ = MKARGS($2); }
+ T_SPACE regp { $$ = MKARGS($2); }
a_regp_reg:
- T_SPACE T_REGPTR "," T_REG { $$ = MKARGS($2, $4); }
+ T_SPACE regp "," reg { $$ = MKARGS($2, $4); }
a_reg_regp:
- T_SPACE T_REG "," T_REGPTR { $$ = MKARGS($2, $4); }
+ T_SPACE reg "," regp { $$ = MKARGS($2, $4); }
a_reg_expr:
- T_SPACE T_REG "," expr { $$ = MKARGS($2, $4); }
+ T_SPACE reg "," expr { $$ = MKARGS($2, $4); }
a_expr:
T_SPACE expr { $$ = MKARGS($2); }
+regp: "@" reg { $$ = $2; }
+reg: T_LABEL {
+ int bad = 0;
+ if ($1[0] != 'r' && $1[0] != 'R')
+ bad = 1;
+ else if (0 > $1[1] - '0' || $1[1] - '0' > 9)
+ bad = 1;
+ else if ($1[2])
+ bad = 1;
+
+ if (bad) {
+ yyerror("invalid register");
+ YYERROR;
+ } else {
+ $$ = MKARGVALUE($1[1] - '0');
+ }
+ }
+
expr:
intlit { $$ = MKARGVALUE($1); }
| T_LABEL { $$ = MKARGLABEL($1); }