# Server imports from http.server import HTTPServer, BaseHTTPRequestHandler import io import os import json # Parser imports import Instrucciones.DML.select as select from Error import * import Librerias.storageManager.jsonMode as storage import gramatica as g import Utils.Lista as l # Data list storage.dropAll() datos = l.Lista({}, '') # Setting server port PORT = 8000 #Def. requests handler. class MyRequestHandler(BaseHTTPRequestHandler): def do_GET(self): #Definiendo rutas para peticiones get if self.path == '/getUsers': self.do_getUsers() elif self.path == '/getDatabases': self.do_getDatabases() else:
def analisis(): global datos salida.delete("1.0", "end") texto = editor.get("1.0", "end") try: f = open("./Utils/tabla.txt", "r") text = f.read() f.close() text = text.replace('\'', '"') text = text.replace('False', '"False"') text = text.replace('None', '""') text = text.replace('True', '"True"') print(text) datos.reInsertarValores(json.loads(text)) print(str(datos)) except: print('error') #g2.tempos.restartTemp() #reinicia el contador de temporales. prueba = g2.parse(texto) #print(prueba['text']) exepy = ''' #imports from goto import with_goto import gramatica as g import Utils.Lista as l import Librerias.storageManager.jsonMode as storage storage.dropAll() heap = [] datos = l.Lista({}, '') ''' exepy += ''' #funcion intermedia def mediador(): global heap # Analisis sintactico instrucciones = g.parse(heap.pop()) for instr in instrucciones['ast'] : print(instr.execute(datos)) ''' exepy += ''' #funciones de plg-sql ''' exepy += ''' #main #@with_goto def main(): global heap ''' exepy += str(prueba['text']) exepy += ''' #Ejecucion del main if __name__ == "__main__": main() ''' f = open("./c3d.py", "w") f.write(exepy) f.close() instrucciones = g.parse(texto) erroresSemanticos = [] try: hacerReporteGramatica(instrucciones['reporte']) except: print("") '''try: f = open("./Utils/tabla.txt", "r") text = f.read() text = text.replace('\'','"') text = text.replace('False','"False"') text = text.replace('None','""') text = text.replace('True','"True"') print(text) datos.reInsertarValores(json.loads(text)) print(str(datos)) except: print('error')''' for instr in instrucciones['ast']: if instr != None: result = instr.execute(datos) if isinstance(result, Error): escribirEnSalidaFinal(str(result.desc)) erroresSemanticos.append(result) elif isinstance(instr, select.Select) or isinstance( instr, select.QuerysSelect): escribirEnSalidaFinal(str(instr.ImprimirTabla(result))) else: escribirEnSalidaFinal(str(result)) f = open("./Utils/tabla.txt", "w") f.write(str(datos)) f.close() errores = g.getMistakes() recorrerErrores(errores) Rerrores(errores, erroresSemanticos) errores.clear() erroresSemanticos.clear() reporteTabla() del instrucciones