def unop(oper): opdo1 = opdos.pop() newtype = semantic_cube.get_type(oper, opdo1['type'], None) if newtype == 'E': error = "Line {lineno}: Can't use {oper} on {op1}" return error.format(oper=oper, op1=opdo1['type']) temp = {'dir': symtable.newtemp(newtype), 'type': newtype} gen_quad(dir.of[oper], opdo1['dir'], -1, temp['dir']) opdos.append(temp)
def unop(oper): opdo1 = opdos.pop() newtype = semantic_cube.get_type(oper, opdo1["type"], None) if newtype == "E": error = "Line {lineno}: Can't use {oper} on {op1}" return error.format(oper=oper, op1=opdo1["type"]) temp = {"dir": symtable.newtemp(newtype), "type": newtype} gen_quad(dir.of[oper], opdo1["dir"], -1, temp["dir"]) opdos.append(temp)
def binop(oper): opdo2 = opdos.pop() opdo1 = opdos.pop() newtype = semantic_cube.get_type(oper, opdo1["type"], opdo2["type"]) if newtype == "E": error = "Line {lineno}: Can't use '{oper}' between {t1} and {t2}" return error.format(lineno="{}", oper=oper, t1=opdo1["type"], t2=opdo2["type"]) temp = {"dir": symtable.newtemp(newtype), "type": newtype} gen_quad(dir.of[oper], opdo1["dir"], opdo2["dir"], temp["dir"]) opdos.append(temp)
def binop(oper): opdo2 = opdos.pop() opdo1 = opdos.pop() newtype = semantic_cube.get_type(oper, opdo1['type'], opdo2['type']) if newtype == 'E': error = "Line {lineno}: Can't use '{oper}' between {t1} and {t2}" return error.format(lineno='{}', oper=oper, t1=opdo1['type'], t2=opdo2['type']) temp = {'dir': symtable.newtemp(newtype), 'type': newtype} gen_quad(dir.of[oper], opdo1['dir'], opdo2['dir'], temp['dir']) opdos.append(temp)
def p_varcte_call(p): '''varcte : call''' var = symtable.proc_table['program']['var_table'][p[1]] tempdir = symtable.newtemp(var['type']) codegen.gen_quad(dir.asigna, var['dir'], -1, tempdir) p[0] = {'dir':tempdir, 'type':var['type']}