def p_registerlist_item_range(p): 'registerlist_item : register TO register' start = p[1] end = p[3] if start.value not in range(0, 16) or end.value not in range(0, 16): raise SyntaxError("Invalid registers %s-%s"%(str(start), str(end))) ls = [] for i in range(start.value, end.value+1): ls.append(instruction.reg(i)) p[0] = ls
def p_registerlist_item_range(p): 'registerlist_item : register TO register' start = p[1] end = p[3] if start.value not in range(0, 16) or end.value not in range(0, 16): raise SyntaxError("Invalid registers %s-%s" % (str(start), str(end))) ls = [] for i in range(start.value, end.value + 1): ls.append(instruction.reg(i)) p[0] = ls
def p_register_pc(p): 'register : PC' p[0] = instruction.reg(15)
def p_register_lr(p): 'register : LR' p[0] = instruction.reg(14)
def p_register_sp(p): 'register : SP' p[0] = instruction.reg(13)
def p_register_fp(p): 'register : IP' p[0] = instruction.reg(12)
def t_REGISTER(t): r'[Rr]\d?\d' t.value = instruction.reg(int(t.value[1:])) return t