diff options
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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); } |