Exemplo n.º 1
0
        public object ejecutar(Entorno.Entorno ent)
        {
            Object ob = expresion.getValor(ent);

            if (ob != null)
            {
                Estatico.agregarMensaje("[+MESSAGE]\n" + ob.ToString() + "\n[-MESSAGE]\n");
            }
            return(null);
        }
Exemplo n.º 2
0
        public object ejecutar(Entorno.Entorno ent)
        {
            if (Estatico.actualBase != null)
            {
                if (Estatico.actualBase.existeTabla(nombre))
                {
                    Tabla actual = Estatico.actualBase.getTabla(nombre);
                    if (todos)
                    {
                        campos = new LinkedList <Expresion>();
                        foreach (Columna col in actual.columnas)
                        {
                            campos.AddLast(new Identificador(col.nombre, this.fila, this.columna));
                        }

                        DataTable tabla_select = GenerarTabla(actual, ent);
                        if (tabla_select != null)
                        {
                            Tabla ntabla = new Tabla("consulta", tabla_select, new LinkedList <string>(), new LinkedList <Columna>());
                            if (this.html)
                            {
                                Estatico.agregarMensaje("[+DATA]" + ntabla.GetTablaHTML() + "[-DATA]");
                            }
                            this.tabla = ntabla;
                        }
                        else
                        {
                            this.tabla = null;
                        }
                    }
                    else
                    {
                        DataTable tabla_select = GenerarTabla(actual, ent);
                        if (tabla_select != null)
                        {
                            Tabla ntabla = new Tabla("consulta", tabla_select, new LinkedList <string>(), new LinkedList <Columna>());
                            if (this.html)
                            {
                                Estatico.agregarMensaje("[+DATA]" + ntabla.GetTablaHTML() + "[-DATA]");
                            }
                            this.tabla = ntabla;
                        }
                        else
                        {
                            this.tabla = null;
                        }
                    }
                }
                else
                {
                    Estatico.errores.Add(new ErrorCQL("Ejecucion", "La tabla: " + nombre + " no existe en la base: " + Estatico.actualBase.nombre, this.fila, this.columna));
                }
            }
            else
            {
                Estatico.errores.Add(new ErrorCQL("Ejecucion", "No hay base en uso", this.fila, this.columna));
            }


            return(null);
        }
Exemplo n.º 3
0
        public void Analizar(String entrada)
        {
            GramaticaCQL  gramatica = new GramaticaCQL();
            LanguageData  lenguaje  = new LanguageData(gramatica);
            Parser        parser    = new Parser(lenguaje);
            ParseTree     arbol     = parser.Parse(entrada);
            ParseTreeNode raiz      = arbol.Root;

            Estatico.errores  = new List <ErrorCQL>();
            Estatico.mensajes = new List <String>();
            Estatico.servidor = new Servidor();
            obteErroes(arbol);


            if (raiz != null)
            {
                Graficador.Graficador grafo = new Graficador.Graficador();
                grafo.graficar(raiz);
                ConstruirAST constructor = new ConstruirAST(raiz);
                AST          arbolAst    = constructor.generarAst();
                Entorno      ent         = new Entorno(null);

                //-------- Prueba;
                BaseDatos prueba = new BaseDatos("prueba");
                Estatico.servidor.nuevaBase("prueba", prueba);
                Usuario admin = new Usuario("admin", "admin");
                Estatico.actualUsuario = admin;

                foreach (NodoAST sentencia in arbolAst.arbol)
                {
                    if (sentencia is Instruccion)
                    {
                        if (sentencia is Funcion)
                        {
                            Funcion fun = (Funcion)sentencia;

                            ent.agregar(fun.identificador, fun);
                        }
                    }
                    else if (sentencia is Expresion)
                    {
                    }
                }

                foreach (NodoAST sentencia in arbolAst.arbol)
                {
                    if (sentencia is Instruccion)
                    {
                        if (!(sentencia is Funcion))
                        {
                            Instruccion ins   = (Instruccion)sentencia;
                            object      valor = ins.ejecutar(ent);
                        }
                    }
                    else if (sentencia is Expresion)
                    {
                        Expresion exp   = (Expresion)sentencia;
                        object    valor = exp.getValor(ent);
                    }
                }

                //por el momento modificar al final


                ReporteErrores reporte = new ReporteErrores(Estatico.errores);
                reporte.writeReport();
            }
            else
            {
                Estatico.agregarMensaje("[+MESSAGE]raiz nula[-MESSAGE]");
                //MessageBox.Show("raiznula");
            }
        }