예제 #1
0
    def ruta_SelectComplejo(self, entorno: Tabla_de_simbolos, arbol: Arbol):
        print("[Select] ruta_SelectComplejo (Go on)")
        V_TablaSelect = Valor(TIPO.MATRIZ, "TablaSelect")
        for i in self.listatablas:
            self.virtualizar_tabla(i, entorno, arbol)

        # ------------------
        j = 0
        for i in self.listavalores:
            if self.obtener_multi(i, entorno, arbol, j):
                break
            j = j + 1
        # ------------------

        V_TablaSelect.inicializarMatrix_boring(self.tamFilaTablaSelect, len(self.listavalores))
        index = 0
        for i in self.listavalores:
            lista: list = self.obtener_columnas(i, entorno, arbol)
            for m in range(len(lista)):
                V_TablaSelect.matriz[m][index] = lista[m]
            index = index + 1
        self.TablaSelect = V_TablaSelect
        # ----------------------------------------------------------------------------------
        TablaSe:Simbolo = Simbolo("TablaResult", 0, self.TablaSelect)
        entorno.insertar_variable(TablaSe)
        for i in self.listawhere:
            i.execute(entorno, arbol)
예제 #2
0
    def ruta_SelectSimple(self, entorno: Tabla_de_simbolos, arbol:Arbol):
        print("[Select] ruta_SelectSimple (Go on)")
        V_TablaSelect = Valor(TIPO.MATRIZ, "TablaSelect")
        for i in self.listatablas:
            if i.tipo == IAT.SUBQUERY:
                self.virtualizar_tabla_subquery(i, entorno, arbol)
            else:
                self.virtualizar_tabla(i, entorno, arbol)

        # ------------------
        j = 0
        for i in self.listavalores:
            if self.obtener_multi(i, entorno, arbol, j):
                break
            j = j + 1
        # ------------------

        V_TablaSelect.inicializarMatrix_boring(self.tamFilaTablaSelect, len(self.listavalores))
        index = 0
        for i in self.listavalores:
            lista:list = self.obtener_columnas(i, entorno, arbol)
            for m in range(len(lista)):
                V_TablaSelect.matriz[m][index] = lista[m]
            index = index + 1
        self.TablaSelect = V_TablaSelect
        arbol.console.append("\n" + self.consolaInterna + self.TablaSelect.inicializarPrettybabe() + "\n")
        return self.TablaSelect
예제 #3
0
    def virtualizar_tabla(self, index:indexador_auxiliar, entorno: Tabla_de_simbolos, arbol:Arbol):
        # -----------------------------------------------
        # Codigo para acceder a estructuras de EDD (estan quemados por el momento)
        # basado en el index.origen
        body = j.extractTable(entorno.getBD(),index.origen)
        x = Meta.getNameColumns(body[0])
        body[0] = x
        # body = [['Cod', 'estado', 'ciudad', 'zona'], [1, 'Guatemala', 'Guatemala', 'GTM'], [2, 'Cuilapa', 'Santa Rosa', 'GTM'], [3, 'San Salvador', 'San Salvador', 'SLV']]
        tamFila = len(body)
        tamColumna = len(body[0])
        if tamFila > self.tamFilaTablaSelect:
            self.tamFilaTablaSelect = tamFila
        '''headers:list = ['C_1', 'C_2', 'C_3', 'C_4', 'C_5']
        body:list = [
            '1.1', '2.1', '3.1', '4.1', '5.1',
            '1.2', '2.2', '3.2', '4.2', '5.2',
            '1.3', '2.3', '3.3', '4.3', '5.3'
        ]'''
        # -----------------------------------------------

        nombreTabla = self. definidorDeNombre_deTabla_basadoEnIndexador(index)
        tablaVirtualizada:Valor = Valor(TIPO.MATRIZ, nombreTabla)
        tablaVirtualizada.inicializarMatrix_boring(tamFila, tamColumna)
        tablaVirtualizada.setearMatriz_byJespino(body)
        #tablaVirtualizada.establecer_encabezados(headers)
        #tablaVirtualizada.setear_body_byList_MATRIZ(body)
        # self.consolaInterna = tablaVirtualizada.consola_imprimirMatriz_NERY()
        tablaVirtualizada.consola_imprimirMatriz_NERY()
        newSimbolo:Simbolo = Simbolo(nombreTabla, TIPO.MATRIZ, tablaVirtualizada)
        entorno.insertar_variable(newSimbolo)

        TSreport = ReporteTS(
            nombreTabla, "Tabla", "Select", 1, 1
        )
        arbol.ReporteTS.append(TSreport)
예제 #4
0
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):
        izquierdo = self.izq.execute(entorno, arbol)
        derecho = self.der.execute(entorno, arbol)

        if self.tipoOperaRelacional == "==":
            retorno:Valor = Valor(3, True);
            return  retorno;
예제 #5
0
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):
        izquierdo: Valor = self.izq.execute(entorno, arbol)
        derecho: Valor = self.der.execute(entorno, arbol)
        tipoRes = COMPROBADOR_deTipos(izquierdo.tipo, derecho.tipo, "-")

        if tipoRes == 0:
            newValor: Valor = Valor(tipoRes, izquierdo.data - derecho.data)
            return newValor
예제 #6
0
 def obtener_columnas(self, index:indexador_auxiliar, entorno: Tabla_de_simbolos, arbol:Arbol):
     campo = self.definidorDeNombre_deTabla_basadoEnIndexador(index)
     tabla = index.origen
     if len(self.listatablas) == 1:
         tabla = self.definidorDeNombre_deTabla_basadoEnIndexador(self.listatablas[0])
     tablaVistualizada:Valor = entorno.obtener_varibale(tabla)
     columna:Valor = Valor(TIPO.LISTA, campo)
     columna.inicizalizar_lista(tablaVistualizada.obtenerColumna_enBase_aEncabezado(campo))
     return  columna.lista
예제 #7
0
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):
        expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero

        if self.tipo == "LENGTH":
            retorno: Valor = Valor(TIPO.NUMERIC, len(expresion.data))
            return retorno
        elif self.tipo == "SUBSTRING" or self.tipo == "SUBSTR":
            substring = expresion.data[self.substart.data: self.subend.data]
            retorno: Valor = Valor(TIPO.CADENA, substring)
            return retorno
        elif self.tipo == "TRIM":
            retorno: Valor = Valor(TIPO.CADENA, expresion.data.strip())
            return retorno
        elif self.tipo == "MD5":
            result = hashlib.md5(expresion.data.encode())
            res = result.hexdigest()
            retorno: Valor = Valor(TIPO.CADENA, res)
            return retorno
        elif self.tipo == "SHA256":
            result = hashlib.sha256(expresion.data.encode())
            res = result.hexdigest()
            retorno: Valor = Valor(TIPO.CADENA, res)
            return retorno
        elif self.tipo == "GET_BYTE":
            result = bytes(expresion.data, "utf-8")
            if len(result) > self.substart.data:
                retorno: Valor = Valor(TIPO.NUMERIC, result[self.substart.data])
                return retorno
        elif self.tipo == "SET_BYTE":
            result = bytes(expresion.data, "utf-8")
            res = result[self.substart.data]
            res2 = bytes(res)
            retorno: Valor = Valor(TIPO.NUMERIC, res2)
            return retorno
        elif self.tipo == "CONVERT":
            date_time_obj = datetime.datetime.strptime(expresion.data, '%d/%m/%y %H:%M:%S')
            retorno: Valor = Valor(TIPO.DATE, date_time_obj)
            return retorno
        elif self.tipo == "ENCODE":
            retorno: Valor = Valor(TIPO.CADENA, expresion.data.encode("UTF-8", "escape"))
            return retorno
        elif self.tipo == "DECODE":
            retorno: Valor = Valor(TIPO.CADENA, expresion.data.decode('base64'))
            return retorno
예제 #8
0
파일: select.py 프로젝트: susanliss/tytus
 def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):
     #for item in self.listavalores:
     #item_:Valor = item.execute(entorno, arbol)
     #print(item_.data)
     #pass
     print(self.ID)
     for item in self.listawhere:
         item_: Valor = item.execute(entorno, arbol)
         print(item_.data)
     pass
     valor_: Valor = Valor(0, 7)
     value: Valor = Valor(666, "Matrix")
     value.inicializarMatrix_boring(5, 5)
     value.consola_imprimirMatriz_NERY()
     encabezados: list = ['1ra', '2da', '3ra', '4ta', '5ta']
     value.establecer_encabezados(encabezados)
     value.ingresar_aMatriz_boring(valor_, 1, 1)
     value.ingresar_aMatriz_boring(valor_, 3, 1)
     value.consola_imprimirMatriz_NERY()
예제 #9
0
파일: type.py 프로젝트: sandymerida/tytus
 def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):
     indentificador = self.indentificador
     value: Valor = Valor(TIPO.LISTA, indentificador)
     lista = []
     for i in self.ListaTipos:
         val: Valor = i.execute(entorno, arbol)
         value.insert_tipo_toType(str(val.data))
         lista.append(str(val.data))
     simbol: Simbolo = Simbolo(indentificador, TIPO.LISTA, value)
     entorno.insertar_variable(simbol)
     arbol.console.append("\n" + "Type: " + indentificador +
                          " --> Valores: " + str(lista) + "\n")
     return
예제 #10
0
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):

        tabla: Valor = Valor(TIPO.MATRIZ, "Select simple simple")
        tabla.inicializarMatrix_boring(2, len(self.lista_exp))
        indexM = 0  # V_TablaSelect.matriz[m][index] = lista[m]

        for i in self.lista_exp:
            if isinstance(i, indexador_auxiliar):
                indexador: indexador_auxiliar = i
                expresion: Valor = indexador.origen.execute(entorno, arbol)
                tabla.matriz[0][indexM] = Valor(TIPO.CADENA,
                                                indexador.referencia)
                tabla.matriz[1][indexM] = expresion
                indexM = indexM + 1
                #arbol.console.append("\n" + "tytus > [" + indexador.referencia + "] : " + str(expresion.data) + "\n")
                pass
            else:
                expresion: Valor = i.execute(entorno, arbol)
                tabla.matriz[0][indexM] = "Funcion"
                tabla.matriz[1][indexM] = expresion
                #arbol.console.append("\n" + "tytus > [Funcion] : " + str(expresion.data) + "\n")
        arbol.console.append("\n" + tabla.inicializarPrettybabe() + "\n")
        return
예제 #11
0
파일: DIVISION.py 프로젝트: edgarJ91/tytus
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):
        izquierdo: Valor = self.izq.execute(entorno, arbol)
        derecho: Valor = self.der.execute(entorno, arbol)

        if derecho == 0:
            Error: ErroresSemanticos = ErroresSemanticos(
                "Error semantico no se puede dividir entre 0", self.linea,
                self.columna, "DIVISION")
            arbol.ErroresSemanticos.append(Error)
        else:
            tipoRes = COMPROBADOR_deTipos(izquierdo.tipo, derecho.tipo, "/")
            if tipoRes == 0:
                newValor: Valor = Valor(tipoRes, izquierdo.data / derecho.data)
                return newValor
예제 #12
0
 def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):
     if self.type == 'extract':
         entry: Valor = self.secondparam.execute(entorno, arbol)
         try:
             result = self.extract(entry)
             print(result)
             retorno: Valor = Valor(TIPO.DATE, result)
             return retorno
         except:
             print('ERROR EN EL FORMATO DE FECHA INGRESADO')
     elif self.type == 'date_part':
         entry: Valor = self.secondparam.execute(entorno, arbol)
         array = entry.data.split(' ')
         if self.firstparam == 'hour':
             print(array[0])
             retorno: Valor = Valor(TIPO.DATE, array[0])
             return retorno
         elif self.firstparam == 'minutes':
             print(array[2])
             retorno: Valor = Valor(TIPO.DATE, array[2])
             return retorno
         elif self.firstparam == 'seconds':
             print(array[4])
             retorno: Valor = Valor(TIPO.DATE, array[4])
             return retorno
     elif self.type == 'now':
         today = str(datetime.now())
         print(today)
         retorno: Valor = Valor(TIPO.DATE, today)
         return retorno
     elif self.type == 'current_date':
         today = str(date.today())
         print(today)
         retorno: Valor = Valor(TIPO.DATE, today)
         return retorno
     elif self.type == 'current_time':
         today = datetime.now()
         now = today.strftime("%H:%M:%S")
         print(now)
         retorno: Valor = Valor(TIPO.DATE, now)
         return retorno
     elif self.type == 'timestamp':
         today = str(datetime.now())
         print(today)
         retorno: Valor = Valor(TIPO.DATE, today)
         return retorno
예제 #13
0
파일: intersect.py 프로젝트: edgarJ91/tytus
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):

        TV_select1: Valor = self.select_1.execute(entorno, arbol)
        TV_select2: Valor = self.select_2.execute(entorno, arbol)

        TV_select2_columna: Valor = Valor(TIPO.LISTA, "COMPARADOR")
        TV_select2_columna.inicizalizar_lista(
            TV_select2.obtenerColumna_enBase_aIndice(0))
        lista_TV_select2 = TV_select2_columna.getLista_sinPareas()

        TV_select1.inicializarPrettybabe()
        valEncabezado: Valor = TV_select1.matriz[0][0]
        encabezado = str(valEncabezado.data)
        for i in lista_TV_select2:
            TV_select1.filtrarWhere_experimental("=", encabezado, str(i.data))

        arbol.console.append("\n" + "Intersect ---> GO" + "\n")
        arbol.console.append(TV_select1.inicializarPrettybabe_experimental())
        arbol.console.append("\n" + "Intersect ---> END" + "\n")
        return
예제 #14
0
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):

        if self.tipocondicionante == "where":
            self.condicionante.execute(entorno, arbol)
            return
        if self.tipocondicionante == "ORDER":
            TablaResult: Valor = entorno.obtener_varibale("TablaResult")
            TablaResult.inicializarPrettybabe()
            consola = TablaResult.order(str(self.condicionante.referencia),
                                        str(self.extra1))
            simbol: Simbolo = Simbolo("TablaResult", 0, TablaResult)
            entorno.insertar_variable(simbol)
            arbol.console.append("\n" + consola + "\n")
        if self.tipocondicionante == "LIMIT":
            limitador = self.condicionante.execute(entorno, arbol)
            TablaResult: Valor = entorno.obtener_varibale("TablaResult")
            TablaResult.inicializarPrettybabe()
            consola = TablaResult.limit(int(limitador.data))
            simbol: Simbolo = Simbolo("TablaResult", 0, TablaResult)
            entorno.insertar_variable(simbol)
            arbol.console.append("\n" + consola + "\n")

        val: Valor = Valor(3, False)
        return val
예제 #15
0
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):

        if self.tipo == "FACTORIAL":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.factorial(int(str(expresion.data))))
            return retorno
        elif self.tipo == "FLOOR":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.floor(float(str(expresion.data))))
            return retorno
        elif self.tipo == "GCD":
            expresion1: Valor = self.exp[0].execute(entorno,
                                                    arbol)  # <--- numero
            expresion2: Valor = self.exp[1].execute(entorno,
                                                    arbol)  # <--- numero
            retorno: Valor = Valor(
                TIPO.DECIMAL,
                math.gcd(int(str(expresion1.data)), int(str(expresion2.data))))
            return retorno
        elif self.tipo == "LN":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.log10(float(str(expresion.data))))
            return retorno
        elif self.tipo == "LOG":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.log(float(str(expresion.data))))
            return retorno
        elif self.tipo == "MOD":
            expresion1: Valor = self.exp[0].execute(entorno,
                                                    arbol)  # <--- numero
            expresion2: Valor = self.exp[1].execute(entorno,
                                                    arbol)  # <--- numero
            v = int(str(expresion1.data)) % int(str(expresion2.data))
            retorno: Valor = Valor(TIPO.DECIMAL, v)
            return retorno
        elif self.tipo == "PI":
            retorno: Valor = Valor(TIPO.DECIMAL, math.pi)
            return retorno
        elif self.tipo == "POWER":
            expresion1: Valor = self.exp[0].execute(entorno,
                                                    arbol)  # <--- numero
            expresion2: Valor = self.exp[1].execute(entorno,
                                                    arbol)  # <--- numero
            v = int(str(expresion1.data))**int(str(expresion2.data))
            retorno: Valor = Valor(TIPO.DECIMAL, v)
            return retorno
        elif self.tipo == "RADIANS":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.radians(float(str(expresion.data))))
            return retorno
        elif self.tipo == "ROUND":
            expresion1: Valor = self.exp[0].execute(entorno,
                                                    arbol)  # <--- numero
            expresion2: Valor = self.exp[1].execute(entorno,
                                                    arbol)  # <--- numero
            retorno: Valor = Valor(
                TIPO.DECIMAL,
                round(float(str(expresion1.data)), int(str(expresion2.data))))
            return retorno
        elif self.tipo == "SIGN":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            v = 0
            if float(str(expresion.data)) > 0:
                v = 1
            else:
                v = -1
            retorno: Valor = Valor(TIPO.DECIMAL, v)
            return retorno
        elif self.tipo == "SQRT":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.sqrt(float(str(expresion.data))))
            return retorno
        elif self.tipo == "TRUNC":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.trunc(float(str(expresion.data))))
            return retorno
        elif self.tipo == "RANDOM":
            retorno: Valor = Valor(TIPO.DECIMAL, random.randrange(1024))
            return retorno
        elif self.tipo == "CBRT":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   self.CBRT(float(str(expresion.data))))
            return retorno
        elif self.tipo == "CEIL":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.ceil(float(str(expresion.data))))
            return retorno
        elif self.tipo == "DEGREES":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.degrees(float(str(expresion.data))))
            return retorno
        elif self.tipo == "DIV":
            expresion1: Valor = self.exp[0].execute(entorno,
                                                    arbol)  # <--- numero
            expresion2: Valor = self.exp[1].execute(entorno,
                                                    arbol)  # <--- numero
            v = int(str(expresion1.data)) / int(str(expresion2.data))
            retorno: Valor = Valor(TIPO.DECIMAL, int(v))
            return retorno
        elif self.tipo == "EXP":
            expresion: Valor = self.exp.execute(entorno, arbol)  # <--- numero
            retorno: Valor = Valor(TIPO.DECIMAL,
                                   math.exp(float(str(expresion.data))))
            return retorno
예제 #16
0
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):
        izquierdo: indexador_auxiliar = self.izq
        derecho: Valor = self.der.execute(entorno, arbol)

        if self.tipoOperaRelacional == "=":
            if entorno.varibaleExiste("TablaResult"):
                TablaResult: Valor = entorno.obtener_varibale("TablaResult")
                TablaResult.inicializarPrettybabe()
                TablaResult.filtrarWhere("=", izquierdo.referencia,
                                         derecho.data)
                simbol: Simbolo = Simbolo("TablaResult", 0, TablaResult)
                entorno.insertar_variable(simbol)
                retorno: bool = not (TablaResult.matriResult_isEmpty())
                arbol.console.append("\n" +
                                     TablaResult.inicializarPrettybabe() +
                                     "\n")
                print(str(retorno) + " <--------------")
                return Valor(3, retorno)
            else:
                # Codigo de Pablo
                # Se crea una lista que contendra o no las llaves primarias que cumplan la condicion
                registers = []
                '''
                    Se obtiene la tabla, el indice de la columna que especifica el lado izquierdo de la operacion 
                    relacional y las llaves primarias
                '''
                table = entorno.gettable()
                pks = Meta.getPksIndex(table[0])
                column = Meta.getNumberColumnByName(izquierdo.get_origen(),
                                                    table[0])
                # Si la columna existe
                if column != -1:
                    # Se recorre cada uno de los registros de la tabla
                    for row in range(len(table)):
                        # Si el registro coincide con el valor
                        if table[row][column] == derecho.data:
                            # Si no hay llaves primarias en la tabla
                            if not pks:
                                registers.append(str([row]))
                            # Si hay llaves primarias en la tabla
                            else:
                                inner = []
                                for pk in pks:
                                    inner.append(str(table[row][pk]) + '|')
                                registers.append(inner)
                # Se devuelven los valores de las llaves primarias de las filas que cumplen la condicion o es vacia
                    return registers
                # Si la columna no existe
                else:
                    '''
                      ______ _____  _____   ____  _____  
                     |  ____|  __ \|  __ \ / __ \|  __ \ 
                     | |__  | |__) | |__) | |  | | |__) |
                     |  __| |  _  /|  _  /| |  | |  _  / 
                     | |____| | \ \| | \ \| |__| | | \ \ 
                     |______|_|  \_\_|  \_\\____/|_|  \_\
                    Descripcion: La columna especificada izquierdo.get_origen() no existe.
                    '''
                    Error: ErroresSemanticos = ErroresSemanticos(
                        "XX01: La columna especificada izquierdo.get_origen() no existe",
                        self.linea, self.columna, 'Operaciones Relacionales')
                    arbol.ErroresSemanticos.append(Error)
                    print(
                        'La columna especificada izquierdo.get_origen() no existe'
                    )
                    return None

        elif self.tipoOperaRelacional == "u:=":
            return {izquierdo: self.der}
예제 #17
0
    def execute(self, entorno: Tabla_de_simbolos, arbol: Arbol):

        if self.tipo == "acos":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                acos = math.acos(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, acos)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "acosd":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                acos = math.acos(math.radians(degree))
                retorno: Valor = Valor(TIPO.DECIMAL, acos)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "asin":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                acos = math.asin(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, acos)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "asind":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                asin = math.asin(math.radians(degree))
                retorno: Valor = Valor(TIPO.DECIMAL, asin)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "atan":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                acos = math.atan(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, acos)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "atan2":
            try:
                value1: Valor = self.exp[0].execute(entorno,
                                                    arbol)  # <--- parametro1
                value2: Valor = self.exp[1].execute(entorno,
                                                    arbol)  # <--- parametro2

                par1 = float(str(value1.data))
                par2 = float(str(value1.data))

                acos = math.atan2(par1, par2)
                retorno: Valor = Valor(TIPO.DECIMAL, acos)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "atan2d":
            try:
                value1: Valor = self.exp[0].execute(entorno,
                                                    arbol)  # <--- parametro1
                value2: Valor = self.exp[1].execute(entorno,
                                                    arbol)  # <--- parametro2

                par1 = float(str(value1.data))
                par2 = float(str(value1.data))

                acos = math.atan2(math.radians(par1), math.radians(par2))
                retorno: Valor = Valor(TIPO.DECIMAL, acos)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "cos":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                acos = math.cos(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, acos)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "cosd":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                cos = math.cos(math.radians(degree))
                retorno: Valor = Valor(TIPO.DECIMAL, cos)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "cot":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                cos = math.cos(degree)
                sin = math.sin(degree)
                cot = cos / sin
                retorno: Valor = Valor(TIPO.DECIMAL, cot)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "cotd":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                cos = math.cos(math.radians(degree))
                sin = math.sin(math.radians(degree))
                cot = cos / sin
                retorno: Valor = Valor(TIPO.DECIMAL, cot)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "sin":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                sin = math.sin(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, sin)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "sind":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                sin = math.sin(math.radians(degree))
                retorno: Valor = Valor(TIPO.DECIMAL, sin)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "tan":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                tan = math.tan(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, tan)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "tand":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                tan = math.tan(math.radians(degree))
                retorno: Valor = Valor(TIPO.DECIMAL, tan)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "sinh":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                sinh = math.sinh(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, sinh)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "cosh":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                cosh = math.cosh(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, cosh)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "tanh":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                tanh = math.tanh(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, tanh)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "asinh":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                asinh = math.asinh(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, asinh)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "acosh":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                acosh = math.acosh(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, acosh)
                return retorno
            except:
                print(traceback)
        elif self.tipo == "atanh":
            try:
                expresion: Valor = self.exp.execute(entorno,
                                                    arbol)  # <--- numero
                degree = float(str(expresion.data))
                atanh = math.atanh(degree)
                retorno: Valor = Valor(TIPO.DECIMAL, atanh)
                return retorno
            except:
                print(traceback)
예제 #18
0
 def NuevoAmbito(self):
     nuevoAmito = [Simbolo("VACIO", 2, Valor(2, "VACIO"))]
     self.Pila_de_tablas.append(nuevoAmito)
예제 #19
0
 def execute(self, entorno:Tabla_de_simbolos, arbol:Arbol):
     value:Valor = Valor(TIPO.BOOLEAN, self.data)
     return value