From 9244eacb5ab0b9a11480d1ad40d4720575676877 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Tue, 17 Jan 2017 20:14:45 -0600 Subject: nqasm: parse labels --- parser.y | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'parser.y') 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 T_LABEL %token T_INT %token T_BADINT %token T_REG %token T_REGPTR + %token T_COMMA "," +%token T_COLON ":" %type inst %type 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); } -- cgit v1.2.3