def execute(self, enviroment): hijo = self.hijos[0] hijo2 = self.hijos[1] res = hijo.execute(enviroment) res2 = hijo2.execute(enviroment) if hijo.tipo.data_type == Data_Type.numeric and hijo2.tipo.data_type == Data_Type.numeric: if res2 == 0 : self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else : self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = res % res2 return self.valorExpresion else : self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): exp = self.hijos[0] exp2 = self.hijos[1] valueExp = exp.execute(enviroment) valueExp2 = exp2.execute(enviroment) if exp.tipo.data_type == Data_Type.numeric and exp2.tipo.data_type == Data_Type.numeric: try: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = math.atan2(valueExp, valueExp2) return self.valorExpresion except: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): op1 = self.hijos[0] res = op1.execute(enviroment) if op1.tipo.data_type == Data_Type.numeric: self.tipo = Type_Expresion(Data_Type.numeric) if res > 0: self.valorExpresion = 1 return self.valorExpresion elif res == 0: self.valorExpresion = 0 return self.valorExpresion elif res < 0: self.valorExpresion = -1 return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def compile(self, enviroment): cantExp = len(self.hijos) if cantExp == 1: exp = self.hijos[0] expValue = exp.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = expValue self.cod += self.dir + ' = math.trunc(' + exp.dir + ')\n' return self.cod else: exp = self.hijos[0] exp2 = self.hijos[1] expValue = exp.compile(enviroment) exp2Value = exp2.compile(enviroment) valor2 = str(instanceTemporal.getTemporal()) factor = str(instanceTemporal.getTemporal()) self.tipo = Type_Expresion(Data_Type.numeric) self.cod = expValue + exp2Value self.cod += valor2 + ' = int(' + exp2.dir + ')\n' self.cod += factor + ' = 10.0 ** ' + valor2 + '\n' self.dir = instanceTemporal.getTemporal() self.cod += self.dir + ' = math.trunc(' + exp.dir + ' * ' + factor + ') / ' + factor + '\n' return self.cod
def execute(self, enviroment): cantExp = len(self.hijos) if cantExp == 1: exp = self.hijos[0] expValue = exp.execute(enviroment) if exp.tipo.data_type == Data_Type.numeric: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = math.trunc(expValue) return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else: exp = self.hijos[0] exp2 = self.hijos[1] expValue = exp.execute(enviroment) exp2Value = exp2.execute(enviroment) if exp.tipo.data_type == Data_Type.numeric and exp2.tipo.data_type == Data_Type.numeric: try: valor2 = int(exp2Value) factor = 10.0**valor2 self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = math.trunc( expValue * factor) / factor return self.valorExpresion except: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): op1 = self.hijos[0] res1 = op1.execute(enviroment) if op1.tipo.data_type == Data_Type.numeric: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = res1 * (math.pi / 180) return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): exp = self.hijos[0] valueExp = exp.execute(enviroment) if exp.tipo.data_type == Data_Type.character : self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = len(valueExp) return self.valorExpresion else : self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): hijo = self.hijos[0] res = hijo.execute(enviroment) if hijo.tipo.data_type == Data_Type.numeric : self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = res*(180/math.pi) return self.valorExpresion else : self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def compile(self, enviroment): exp = self.hijos[0] minValue = self.hijos[1] maxValue = self.hijos[2] num_buckets = self.hijos[3] valorExp = exp.compile(enviroment) valorMinValue = minValue.compile(enviroment) valorMaxValue = maxValue.compile(enviroment) valorNum_Buckets = num_buckets.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.cod = valorExp + valorMinValue + valorMaxValue + valorNum_Buckets rango = str(instanceTemporal.getTemporal()) self.dir = instanceTemporal.getTemporal() self.cod += rango + '= ' + exp.dir + ' - ' + minValue.dir + '\n' self.cod += self.dir + ' = -1\n' self.cod += 'if ' + rango + ' == 0 :\n' self.cod += '\t'+self.dir + ' = 0\n' self.cod += 'else:\n' self.cod += '\tif ' + num_buckets.dir + ' == 0 :\n' self.cod += '\t\t'+self.dir + ' = 0\n' enteroValorNum_Buckets = str(instanceTemporal.getTemporal()) self.cod += '\telse:\n' self.cod += '\t\t' + enteroValorNum_Buckets + ' = int(' + num_buckets.dir + ')\n' interval = str(instanceTemporal.getTemporal()) self.cod += '\t\t' + interval + ' = (' + rango + ' * 1.0) / (' + enteroValorNum_Buckets + ' * 1.0)\n' variableAuxiliar = str(instanceTemporal.getTemporal()) valorMax = str(instanceTemporal.getTemporal()) valorMin = str(instanceTemporal.getTemporal()) auxiliar = str(instanceTemporal.getTemporal()) self.cod += '\t\t' + variableAuxiliar + ' = ' + minValue.dir +'\n' self.cod += '\t\t' + valorMax + ' = 0\n' self.cod += '\t\t' + valorMin + ' = 0\n' self.cod += '\t\t' + auxiliar + ' = 1\n\n' self.cod += '\t\tif ' + rango + ' > 0 :\n\n' self.cod += '\t\t\tif ' + exp.dir + ' < ' + minValue.dir + ' :\n' self.cod += '\t\t\t\t' + self.dir + ' = 0\n\n' self.cod += '\t\t\twhile ' + variableAuxiliar + ' <= ' +maxValue.dir + ' : \n\n' self.cod += '\t\t\t\t' + valorMin + ' = ' + variableAuxiliar + '\n' self.cod += '\t\t\t\t' + valorMax + ' = ' + variableAuxiliar + ' + ' + interval + '\n' self.cod += '\t\t\t\tif ' + exp.dir + ' >= ' + valorMin + ' and ' + exp.dir + ' < ' + valorMax + ' :\n' self.cod += '\t\t\t\t\tbreak\n\n' self.cod += '\t\t\t\t' + variableAuxiliar + ' = ' + variableAuxiliar + ' + ' + interval + '\n' self.cod += '\t\t\t\t' + auxiliar + ' = ' + auxiliar + ' + 1\n' self.cod += '\t\t\t' + self.dir + ' = ' + auxiliar + '\n' self.cod += '\t\telse:\n' self.cod += '\t\t\tif ' + exp.dir + ' > ' + minValue.dir + ' :\n' self.cod += '\t\t\t\t' + self.dir + ' = 0\n\n' self.cod += '\t\t\twhile ' + variableAuxiliar + ' >= ' +maxValue.dir + ' : \n\n' self.cod += '\t\t\t\t' + valorMin + ' = ' + variableAuxiliar + '\n' self.cod += '\t\t\t\t' + valorMax + ' = ' + variableAuxiliar + ' + ' + interval + '\n' self.cod += '\t\t\t\tif ' + exp.dir + ' <= ' + valorMin + ' and ' + exp.dir + ' > ' + valorMax + ' :\n' self.cod += '\t\t\t\t\tbreak\n\n' self.cod += '\t\t\t\t' + variableAuxiliar + ' = ' + variableAuxiliar + ' + ' + interval + '\n' self.cod += '\t\t\t\t' + auxiliar + ' = ' + auxiliar + ' + 1\n' self.cod += '\t\t\t' + self.dir + ' = ' + auxiliar return self.cod
def execute(self, enviroment): op1 = self.hijos[0] op2 = self.hijos[1] res1 = op1.execute(enviroment) res2 = op2.execute(enviroment) if op1.tipo.data_type == Data_Type.numeric and op2.tipo.data_type == Data_Type.numeric: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = round(res1, res2) return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): self.hijos[0].execute(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = 1 global selectAgregate selectAgregate.pop(-1) selectAgregate.append("COUNT") return 1
def compile(self, enviroment): hijo = self.hijos[0] res = hijo.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = res self.cod += self.dir + ' = ' + hijo.dir + ' ** ( 1. / 3. )\n' return self.cod
def compile(self, enviroment): exp = self.hijos[0] valueExp = exp.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = valueExp self.cod += self.dir + ' = math.asinh(' + exp.dir + ')\n' return self.cod
def compile(self, enviroment): exp = self.hijos[0] cod = exp.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = cod self.cod += self.dir + ' = math.acos(' + exp.dir + ') * ( 180. / math.pi )' + '\n' return self.cod
def compile(self, enviroment): op1 = self.hijos[0] res1 = op1.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = res1 self.cod += self.dir + ' = ' + op1.dir + '*( math.pi / 180 )\n' return self.cod
def execute(self, enviroment): self.tipo = Type_Expresion(Data_Type.boolean) if self.valor.lower() == 'true': self.valorExpresion = True else: self.valorExpresion = False return self.valorExpresion
def execute(self, enviroment): hijo = self.hijos[0] res = hijo.execute(enviroment) if hijo.tipo.data_type == Data_Type.numeric : self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = round(res) if self.valorExpresion > res : self.valorExpresion = self.valorExpresion - 1 return self.valorExpresion else : self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def compile(self, enviroment): self.tipo = Type_Expresion(Data_Type.boolean) self.cod = '' if self.valor.lower() == 'true': self.dir = str(1) return self.cod else: self.dir = str(0) return self.cod
def compile(self, enviroment): exp = self.hijos[0] valueExp = exp.compile(enviroment) self.tipo = Type_Expresion(Data_Type.character) self.dir = instanceTemporal.getTemporal() self.cod = valueExp self.cod += self.dir + ' = ' + exp.dir + '.strip()' return self.cod
def execute(self, enviroment): self.tipo = Type_Expresion(Data_Type.character) newString = self.valor.replace('\\b', '\b') newString = newString.replace('\\f', '\f') newString = newString.replace('\\n', '\n') newString = newString.replace('\\t', '\t') newString = newString.replace('\\r', '\r') self.valorExpresion = newString return self.valorExpresion
def execute(self, enviroment): hijo = self.hijos[0] res = hijo.execute(enviroment) if hijo.tipo.data_type == Data_Type.numeric: if res > -1: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = res**(1. / 3.) return self.valorExpresion else: self.valorExpresion = None self.tipo = Type_Expresion(Data_Type.error) return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None # Reportar Error return self.valorExpresion
def compile(self, enviroment): hijo = self.hijos[0] res = hijo.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = res self.cod += self.dir + ' = round(' + hijo.dir + ')\n' self.cod += 'if ' + self.dir + ' > ' + hijo.dir + ' :\n' self.cod += '\t' + self.dir + ' = ' + self.dir + ' - 1\n' return self.cod
def compile(self, enviroment): hijo = self.hijos[0] hijo2 = self.hijos[1] res = hijo.compile(enviroment) res2 = hijo2.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = res + res2 self.cod += self.dir + ' = ' + hijo.dir + '%' + hijo2.dir + '\n' return self.cod
def compile(self, enviroment): exp = self.hijos[0] exp2 = self.hijos[1] valueExp = exp.compile(enviroment) valueExp2 = exp2.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = valueExp + valueExp2 self.cod += self.dir + ' = math.atan2(' + exp.dir + ',' + exp2.dir + ') * ( 180 / math.pi )\n' return self.cod
def compile(self, enviroment): op1 = self.hijos[0] op2 = self.hijos[1] res1 = op1.compile(enviroment) res2 = op2.compile(enviroment) self.tipo = Type_Expresion(Data_Type.numeric) self.dir = instanceTemporal.getTemporal() self.cod = res1 + res2 self.cod += self.dir + ' = round(' + op1.dir + ',' + op2.dir + ')\n' return self.cod
def execute(self, enviroment): hijo = self.hijos[0] res = hijo.execute(enviroment) if hijo.tipo.data_type == Data_Type.numeric: try: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = math.factorial(res) return self.valorExpresion except: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): op1 = self.hijos[0] res = op1.execute(enviroment) if op1.tipo.data_type == Data_Type.numeric: if res > -1: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = res**(1. / 2.) return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): hijo = self.hijos[0] hijo2 = self.hijos[1] res = hijo.execute(enviroment) res2 = hijo2.execute(enviroment) if hijo.tipo.data_type == Data_Type.numeric and hijo2.tipo.data_type == Data_Type.numeric: try: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = math.gcd(res, res2) return self.valorExpresion except: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): exp = self.hijos[0] valueExp = exp.execute(enviroment) if exp.tipo.data_type == Data_Type.numeric: try: self.tipo = Type_Expresion(Data_Type.numeric) self.valorExpresion = math.atan(valueExp) * (180. / math.pi) return self.valorExpresion except: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else: self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion
def execute(self, enviroment): exp = self.hijos[0] exp2 = self.hijos[1] exp3 = self.hijos[2] valueExp = exp.execute(enviroment) valueExp2 = exp2.execute(enviroment) valueExp3 = exp3.execute(enviroment) if exp.tipo.data_type == Data_Type.character : if exp2.tipo.data_type == Data_Type.numeric and exp3.tipo.data_type == Data_Type.numeric : try : rango = slice(valueExp2-1, valueExp3) self.tipo = Type_Expresion(Data_Type.character) self.valorExpresion = valueExp[rango] return self.valorExpresion except : self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else : self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion else : self.tipo = Type_Expresion(Data_Type.error) self.valorExpresion = None return self.valorExpresion