summaryrefslogtreecommitdiff
path: root/parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y13
1 files changed, 11 insertions, 2 deletions
diff --git a/parser.y b/parser.y
index 76748de..1f4f5bd 100644
--- a/parser.y
+++ b/parser.y
@@ -29,6 +29,7 @@ void yyerror(const char *msg)
struct arguments args;
struct argument arg;
long lval;
+ char *str;
}
%token END 0 "end of file"
@@ -72,12 +73,15 @@ void yyerror(const char *msg)
%token T_ADDPC
%token T_NOP
+%token <str> T_LABEL
%token <lval> T_INT
%token T_BADINT
%token <arg> T_REG
%token <arg> T_REGPTR
+
%token T_COMMA ","
+%token T_COLON ":"
%type <inst> inst
%type <arg> imm
@@ -98,11 +102,16 @@ input: line
| input line
;
-line: T_SPACE inst eol
- { add_instruction(&$2); }
+line:
+ bol inst eol { add_instruction(&$2); }
| eol
;
+bol:
+ T_SPACE
+ | T_LABEL ":" { add_label($1); }
+ ;
+
inst:
T_ADD a_reg3 { $$ = INSTRUCTION_ARGS(ADD, $2); }
| T_SUB a_reg3 { $$ = INSTRUCTION_ARGS(SUB, $2); }