コード例 #1
0
ファイル: SetByte.py プロジェクト: Yadira-Ferrer/tytus
 def ejecutar(self, tabla, arbol):
     super().ejecutar(tabla,arbol)
     if isinstance(self.valor, Primitivo):
         if self.indice <len(self.valor.valor):
             if self.valor.tipo.tipo== Tipo_Dato.CHAR or self.valor.tipo.tipo== Tipo_Dato.VARCHAR or self.valor.tipo.tipo== Tipo_Dato.VARYING or self.valor.tipo.tipo== Tipo_Dato.CHARACTER or self.valor.tipo.tipo== Tipo_Dato.TEXT:
                 cadena =""
                 cont=0
                 for letra in str(self.valor.valor):
                     if(cont==int(self.indice)):
                         cadena+= chr(self.caracter)
                         cont +=1
                         continue                    
                     cadena += letra
                     cont +=1
                 return cadena
         else:
             error = Excepcion('2202E',"Semántico",f"El índice {self.indice} esta fuera de rango [0..{len(self.valor.valor)}]",self.linea,self.columna)
             arbol.excepciones.append(error)
             arbol.consola.append(error.toString())
             return error
     elif isinstance(self.valor,Identificador):
         print("FALTA PROGRAMAR PARA IDENTIFICADOR SET_BYTE")
     error = Excepcion('42883',"Semántico",f"No existe la función SET_BYTE({self.valor.tipo.toString()})",self.linea,self.columna)
     arbol.excepciones.append(error)
     arbol.consola.append("HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos.")
     arbol.consola.append(error.toString())
     return error
コード例 #2
0
ファイル: GetByte.py プロジェクト: Sohanyuuu/tytus
 def ejecutar(self, tabla, arbol):
     super().ejecutar(tabla, arbol)
     resultado = self.valor.ejecutar(tabla, arbol)
     if isinstance(resultado, Excepcion):
         return resultado
     if self.indice < len(resultado):
         if self.valor.tipo.tipo == Tipo_Dato.CHAR or self.valor.tipo.tipo == Tipo_Dato.VARCHAR or self.valor.tipo.tipo == Tipo_Dato.VARYING or self.valor.tipo.tipo == Tipo_Dato.CHARACTER or self.valor.tipo.tipo == Tipo_Dato.TEXT:
             self.tipo = Tipo(Tipo_Dato.INTEGER)
             return ord(
                 str(resultado)[int(self.indice):int(self.indice) + 1])
     else:
         error = Excepcion(
             '2202E', "Semántico",
             f"El índice {self.indice} esta fuera de rango [0..{len(self.valor.valor)}]",
             self.linea, self.columna)
         arbol.excepciones.append(error)
         arbol.consola.append(error.toString())
         return error
     error = Excepcion(
         '42883', "Semántico",
         f"No existe la función GET_BYTE({self.valor.tipo.toString()})",
         self.linea, self.columna)
     arbol.excepciones.append(error)
     arbol.consola.append(
         "HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos."
     )
     arbol.consola.append(error.toString())
     return error
コード例 #3
0
    def ejecutar(self, tabla, arbol):
        super().ejecutar(tabla, arbol)
        resultado = self.valor.ejecutar(tabla, arbol)
        if isinstance(resultado, Excepcion):
            return resultado
        if self.valor.tipo.tipo == Tipo_Dato.CHAR or self.valor.tipo.tipo == Tipo_Dato.CHARACTER or self.valor.tipo.tipo == Tipo_Dato.TEXT:
            if str(self.codificacion.valor) == 'base64':
                message_bytes = resultado.encode('ascii')
                base64_bytes = base64.b64decode(message_bytes)
                base64_message = base64_bytes.decode('ascii')
                resultado = base64_message
                self.tipo = Tipo(Tipo_Dato.TEXT)
                return resultado
            if str(self.codificacion.valor) == 'hex':
                self.tipo = Tipo(Tipo_Dato.TEXT)
                #bytes.fromhex('7061756c').decode('utf-8')
                return bytearray.fromhex(str(resultado)).decode()

        error = Excepcion(
            '22023', "Semántico",
            f"No se reconoce la codificación{self.valor.tipo.toString()})",
            self.linea, self.columna)
        arbol.excepciones.append(error)
        #arbol.consola.append("HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos.")
        arbol.consola.append(error.toString())
        return error
コード例 #4
0
 def ejecutar(self, tabla, arbol):
     super().ejecutar(tabla,arbol)
     if isinstance(self.valor, Primitivo):
         if self.valor.tipo.tipo== Tipo_Dato.CHAR or self.valor.tipo.tipo== Tipo_Dato.VARCHAR or self.valor.tipo.tipo== Tipo_Dato.VARYING or self.valor.tipo.tipo== Tipo_Dato.CHARACTER or self.valor.tipo.tipo== Tipo_Dato.TEXT:
             return hashlib.sha256(str().encode()).hexdigest() 
     elif isinstance(self.valor,Identificador):
         print("FALTA PROGRAMAR PARA IDENTIFICADOR SHA256")
     error = Excepcion('42883',"Semántico",f"No existe la función SHA256({self.valor.tipo.toString()})",self.linea,self.columna)
     arbol.excepciones.append(error)
     arbol.consola.append("HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos.")
     arbol.consola.append(error.toString())
     return error
コード例 #5
0
ファイル: Md5.py プロジェクト: Sohanyuuu/tytus
 def ejecutar(self, tabla, arbol):
     super().ejecutar(tabla,arbol)
     resultado = self.valor.ejecutar(tabla,arbol)
     if isinstance(resultado, Excepcion):
         return resultado
     if self.valor.tipo.tipo== Tipo_Dato.CHAR or self.valor.tipo.tipo== Tipo_Dato.VARCHAR or self.valor.tipo.tipo== Tipo_Dato.VARYING or self.valor.tipo.tipo== Tipo_Dato.CHARACTER or self.valor.tipo.tipo== Tipo_Dato.TEXT:
         self.tipo= Tipo(Tipo_Dato.TEXT)
         return hashlib.md5(str(resultado).encode("utf-8")).hexdigest() 
     error = Excepcion('42883',"Semántico",f"No existe la función MD5({self.valor.tipo.toString()})",self.linea,self.columna)
     arbol.excepciones.append(error)
     arbol.consola.append("HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos.")
     arbol.consola.append(error.toString())
     return error
コード例 #6
0
 def ejecutar(self, tabla, arbol):
     super().ejecutar(tabla,arbol)
     resultado = self.valor.ejecutar(tabla,arbol)
     if isinstance(resultado, Excepcion):
         return resultado
     #print("RESULTADO:",resultado)
     #if isinstance(resultado, Primitivo):
     if self.valor.tipo.tipo== Tipo_Dato.CHAR or self.valor.tipo.tipo== Tipo_Dato.VARCHAR or self.valor.tipo.tipo== Tipo_Dato.VARYING or self.valor.tipo.tipo== Tipo_Dato.CHARACTER or self.valor.tipo.tipo== Tipo_Dato.TEXT:
     #if self.valor.tipo.tipo== Tipo_Dato.CHAR or self.valor.tipo.tipo== Tipo_Dato.CHARACTER:
             self.tipo = Tipo(Tipo_Dato.INTEGER)
             return len(str(resultado)) 
     #elif isinstance(resultado, Identificador):
     #    print("HAY QUE PROGRAMAR LO DE IDENTIFICADOR LENGTH")
     error = Excepcion('42883',"Semántico",f"No existe la función LENGTH({self.valor.tipo.toString()})",self.linea,self.columna)
     arbol.excepciones.append(error)
     arbol.consola.append("HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos.")
     arbol.consola.append(error.toString())
     return error