def p_vrn1(t): '''vrn : SPVAR | RVAR''' if t[1] == "$sp": t[0] = Assignment(0, RegisterType.SPVAR, None, t.lexer.lexdata[0:t.lexer.lexpos].count("\n") + 1) elif t[1] == "$ra": t[0] = Assignment(0, RegisterType.RVAR, None, t.lexer.lexdata[0:t.lexer.lexpos].count("\n") + 1)
def p_vrn(t): '''vrn : TVAR | AVAR | VVAR | SVAR''' type_ = str(t[1][1:2]) idxVar = int(t[1][2:]) if type_ == "t": t[0] = Assignment(idxVar, RegisterType.TVAR, None, t.lexer.lexdata[0:t.lexer.lexpos].count("\n") + 1) elif type_ == "a": t[0] = Assignment(idxVar, RegisterType.AVAR, None, t.lexer.lexdata[0:t.lexer.lexpos].count("\n") + 1) elif type_ == "v": t[0] = Assignment(idxVar, RegisterType.VVAR, None, t.lexer.lexdata[0:t.lexer.lexpos].count("\n") + 1) elif type_ == "s": t[0] = Assignment(idxVar, RegisterType.SVAR, None, t.lexer.lexdata[0:t.lexer.lexpos].count("\n") + 1)
def p_vrn_sp(t): '''vrn : SPVAR''' t[0] = Assignment(0, RegisterType.SPVAR, None, t.lexer.lexdata[0:t.lexer.lexpos].count("\n") + 1)
def p_vrn_s(t): '''vrn : SVAR''' idxVar = int(t[1][2:]) t[0] = Assignment(idxVar, RegisterType.SVAR, None, t.lexer.lexdata[0:t.lexer.lexpos].count("\n") + 1)