From a339532b50bfc4ad36fc3225bf75eae28dee1a4c Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sat, 14 Jan 2017 16:14:19 -0600 Subject: nqasm: Rename arglist non-terminals to a_* This will allow differentiation between pcoff (a single argument) and a_pcoff (an argument list consisting of only a pcoff argument). --- parser.y | 85 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 39 deletions(-) (limited to 'parser.y') diff --git a/parser.y b/parser.y index c953aa4..2d34400 100644 --- a/parser.y +++ b/parser.y @@ -81,12 +81,12 @@ void yyerror(const char *msg) %type inst %type imm -%type reg2 -%type reg3 -%type regp -%type regp_reg -%type reg_regp -%type reg_imm +%type a_reg2 +%type a_reg3 +%type a_regp +%type a_regp_reg +%type a_reg_regp +%type a_reg_imm %type intlit %% @@ -100,31 +100,32 @@ line: T_SPACE inst eol | eol ; -inst: T_ADD reg3 { $$ = INSTRUCTION_ARGS(ADD, $2); } - | T_SUB reg3 { $$ = INSTRUCTION_ARGS(SUB, $2); } - | T_MUL reg3 { $$ = INSTRUCTION_ARGS(MUL, $2); } - | T_DIV reg3 { $$ = INSTRUCTION_ARGS(DIV, $2); } - | T_AND reg3 { $$ = INSTRUCTION_ARGS(AND, $2); } - | T_OR reg3 { $$ = INSTRUCTION_ARGS(OR, $2); } - | T_XOR reg3 { $$ = INSTRUCTION_ARGS(XOR, $2); } - | T_LSL reg3 { $$ = INSTRUCTION_ARGS(LSL, $2); } - | T_LSR reg3 { $$ = INSTRUCTION_ARGS(LSR, $2); } - | T_ASL reg3 { $$ = INSTRUCTION_ARGS(ASL, $2); } - | T_ASR reg3 { $$ = INSTRUCTION_ARGS(ASR, $2); } - | T_ROL reg3 { $$ = INSTRUCTION_ARGS(ROL, $2); } - | T_ROR reg3 { $$ = INSTRUCTION_ARGS(ROR, $2); } - | T_NOT reg2 { $$ = INSTRUCTION_ARGS(NOT, $2); } - | T_NEG reg2 { $$ = INSTRUCTION_ARGS(NEG, $2); } - | T_BTC reg2 { $$ = INSTRUCTION_ARGS(BTC, $2); } - | T_BTS reg2 { $$ = INSTRUCTION_ARGS(BTS, $2); } - | T_MOV reg2 { $$ = INSTRUCTION_ARGS(MOV, $2); } - | T_ST_B regp_reg { $$ = INSTRUCTION_ARGS(ST_B, $2); } - | T_ST_W regp_reg { $$ = INSTRUCTION_ARGS(ST_W, $2); } - | T_LD_BL reg_regp { $$ = INSTRUCTION_ARGS(LD_BL, $2); } - | T_LD_BH reg_regp { $$ = INSTRUCTION_ARGS(LD_BH, $2); } - | T_LD_W reg_regp { $$ = INSTRUCTION_ARGS(LD_W, $2); } - | T_LDI_BL reg_imm { $$ = INSTRUCTION_ARGS(LDI_BL, $2); } - | T_LDI_BH reg_imm { $$ = INSTRUCTION_ARGS(LDI_BH, $2); } +inst: + T_ADD a_reg3 { $$ = INSTRUCTION_ARGS(ADD, $2); } + | T_SUB a_reg3 { $$ = INSTRUCTION_ARGS(SUB, $2); } + | T_MUL a_reg3 { $$ = INSTRUCTION_ARGS(MUL, $2); } + | T_DIV a_reg3 { $$ = INSTRUCTION_ARGS(DIV, $2); } + | T_AND a_reg3 { $$ = INSTRUCTION_ARGS(AND, $2); } + | T_OR a_reg3 { $$ = INSTRUCTION_ARGS(OR, $2); } + | T_XOR a_reg3 { $$ = INSTRUCTION_ARGS(XOR, $2); } + | T_LSL a_reg3 { $$ = INSTRUCTION_ARGS(LSL, $2); } + | T_LSR a_reg3 { $$ = INSTRUCTION_ARGS(LSR, $2); } + | T_ASL a_reg3 { $$ = INSTRUCTION_ARGS(ASL, $2); } + | T_ASR a_reg3 { $$ = INSTRUCTION_ARGS(ASR, $2); } + | T_ROL a_reg3 { $$ = INSTRUCTION_ARGS(ROL, $2); } + | T_ROR a_reg3 { $$ = INSTRUCTION_ARGS(ROR, $2); } + | T_NOT a_reg2 { $$ = INSTRUCTION_ARGS(NOT, $2); } + | T_NEG a_reg2 { $$ = INSTRUCTION_ARGS(NEG, $2); } + | T_BTC a_reg2 { $$ = INSTRUCTION_ARGS(BTC, $2); } + | T_BTS a_reg2 { $$ = INSTRUCTION_ARGS(BTS, $2); } + | T_MOV a_reg2 { $$ = INSTRUCTION_ARGS(MOV, $2); } + | T_ST_B a_regp_reg { $$ = INSTRUCTION_ARGS(ST_B, $2); } + | T_ST_W a_regp_reg { $$ = INSTRUCTION_ARGS(ST_W, $2); } + | T_LD_BL a_reg_regp { $$ = INSTRUCTION_ARGS(LD_BL, $2); } + | T_LD_BH a_reg_regp { $$ = INSTRUCTION_ARGS(LD_BH, $2); } + | T_LD_W a_reg_regp { $$ = INSTRUCTION_ARGS(LD_W, $2); } + | T_LDI_BL a_reg_imm { $$ = INSTRUCTION_ARGS(LDI_BL, $2); } + | T_LDI_BH a_reg_imm { $$ = INSTRUCTION_ARGS(LDI_BH, $2); } | T_BEQ { $$ = INSTRUCTION(BEQ); } | T_BNE @@ -139,18 +140,24 @@ inst: T_ADD reg3 { $$ = INSTRUCTION_ARGS(ADD, $2); } { $$ = INSTRUCTION(BLE); } | T_BRA { $$ = INSTRUCTION(BRA); } - | T_JMP regp { $$ = INSTRUCTION_ARGS(JMP, $2); } - | T_ADDPC reg_imm { $$ = INSTRUCTION_ARGS(ADDPC, $2); } + | T_JMP a_regp { $$ = INSTRUCTION_ARGS(JMP, $2); } + | T_ADDPC a_reg_imm { $$ = INSTRUCTION_ARGS(ADDPC, $2); } | T_NOP { $$ = INSTRUCTION(NOP); } ; -reg2: T_SPACE T_REG "," T_REG { $$ = MKARGS($2, $4); } -reg3: T_SPACE T_REG "," T_REG "," T_REG { $$ = MKARGS($2, $4, $6); } -regp: T_SPACE T_REGPTR { $$ = MKARGS($2); } -regp_reg: T_SPACE T_REGPTR "," T_REG { $$ = MKARGS($2, $4); } -reg_regp: T_SPACE T_REG "," T_REGPTR { $$ = MKARGS($2, $4); } -reg_imm: T_SPACE T_REG "," imm { $$ = MKARGS($2, $4); } +a_reg2: + T_SPACE T_REG "," T_REG { $$ = MKARGS($2, $4); } +a_reg3: + T_SPACE T_REG "," T_REG "," T_REG { $$ = MKARGS($2, $4, $6); } +a_regp: + T_SPACE T_REGPTR { $$ = MKARGS($2); } +a_regp_reg: + T_SPACE T_REGPTR "," T_REG { $$ = MKARGS($2, $4); } +a_reg_regp: + T_SPACE T_REG "," T_REGPTR { $$ = MKARGS($2, $4); } +a_reg_imm: + T_SPACE T_REG "," imm { $$ = MKARGS($2, $4); } imm: intlit { if (-0x80 > $1 || $1 > 0xff) { -- cgit v1.2.3