コード例 #1
0
        public object ejecutar(Entorno.Entorno ent)
        {
            if (Estatico.actualBase != null)
            {
                if (noexiste)
                {
                    bool existe = Estatico.actualBase.existeTabla(nombre);
                    if (Estatico.actualBase.existeTabla(nombre))
                    {
                        Estatico.actualBase.eliminarTabla(nombre);
                    }
                }
                else
                {
                    if (Estatico.actualBase.existeTabla(nombre))
                    {
                        Estatico.actualBase.eliminarTabla(nombre);
                    }
                    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);
        }
コード例 #2
0
ファイル: Use.cs プロジェクト: DouglasAC/Proyecto01Compi2
        public object ejecutar(Entorno.Entorno ent)
        {
            if (Estatico.servidor.existeBase(nombre))
            {
                BaseDatos usar = Estatico.servidor.getBase(nombre);
                if (Estatico.actualUsuario.nombre.Equals("admin"))
                {
                    Estatico.actualBase = usar;
                }
                else if (Estatico.actualUsuario.tienePermiso(nombre))
                {
                    Estatico.actualBase = usar;
                }
                else
                {
                    Estatico.errores.Add(new ErrorCQL("Ejecucion", "El usuario: " + Estatico.actualUsuario.nombre + " No tiene permisos en la base: " + usar.nombre, this.fila, this.columna));
                }
            }
            else
            {
                Estatico.errores.Add(new ErrorCQL("Ejecucion", "La base: " + nombre + " no existe", this.fila, this.columna));
            }

            return(null);
        }
コード例 #3
0
        public object getValor(Entorno.Entorno ent)
        {
            String nombre = this.identificador + "_";

            if (valores != null)
            {
                foreach (Expresion exp in this.valores)
                {
                    Tipo t = exp.getTipo(ent);
                    nombre += t.tipo + "_";
                }
            }
            if (ent.existe(nombre))
            {
                Funcion         funcion = (Funcion)ent.get(nombre);
                Entorno.Entorno global  = ent.gloval();
                Entorno.Entorno local   = new Entorno.Entorno(global);
                if (verificarParametros(valores, funcion.parametros, local, ent))
                {
                    Object val = funcion.ejecutar(local);

                    return(val);
                }
            }
            else
            {
                Estatico.errores.Add(new ErrorCQL("Semantico", "Error en la funcion " + identificador + " no tiene la misma cantidad de parametros o los tipos de parametro no coinciden o no existe", this.fila, this.columna));
            }
            return(null);
        }
コード例 #4
0
ファイル: Today.cs プロジェクト: DouglasAC/Proyecto01Compi2
        public object getValor(Entorno.Entorno ent)
        {
            DateTime localDate = DateTime.Now;
            int      year      = localDate.Year;
            int      mes       = localDate.Month;
            int      dia       = localDate.Day;

            String fecha = year.ToString() + "-";

            if (mes < 10)
            {
                fecha += "0";
            }
            fecha += mes + "-";

            if (dia < 10)
            {
                fecha += "0";
            }
            fecha += dia;

            Date nuevo = new Date(fecha);

            return(nuevo);
        }
コード例 #5
0
 public object getValor(Entorno.Entorno ent)
 {
     if (coleccion != null)
     {
         if (coleccion is Lista)
         {
             Lista  l       = (Lista)coleccion;
             Object val     = valor.getValor(ent);
             Tipo   valtipo = valor.getTipo(ent);
             return(l.contiene(val, valtipo));
         }
         else if (coleccion is Map)
         {
             Map    m   = (Map)coleccion;
             Object val = valor.getValor(ent);
             return(m.contiene(val));
         }
         else if (coleccion is Set)
         {
             Set    l       = (Set)coleccion;
             Object val     = valor.getValor(ent);
             Tipo   valtipo = valor.getTipo(ent);
             return(l.contiene(val, valtipo));
         }
     }
     return(null);
 }
コード例 #6
0
 public object ejecutar(Entorno.Entorno ent)
 {
     if (Estatico.servidor.existeUsuario(nombre))
     {
         if (Estatico.servidor.existeBase(nombre_base))
         {
             if (!Estatico.servidor.GetUsuario(nombre).tienePermiso(nombre_base))
             {
                 Estatico.servidor.GetUsuario(nombre).agregarPeermiso(nombre_base);
             }
             else
             {
                 Estatico.errores.Add(new ErrorCQL("Ejecucion", "El usuario: " + nombre + ", ya tiene perimiso en la base: " + nombre_base, this.fila, this.columna));
             }
         }
         else
         {
             Estatico.errores.Add(new ErrorCQL("Ejecucion", "La base: " + nombre_base + ", no existe ", this.fila, this.columna));
         }
     }
     else
     {
         Estatico.errores.Add(new ErrorCQL("Ejecucion", "El usuario: " + nombre + ", no existe ", this.fila, this.columna));
     }
     return(null);
 }
コード例 #7
0
        public object ejecutar(Entorno.Entorno ent)
        {
            if (noexiste)
            {
                if (!(Estatico.servidor.existeBase(nombre)))
                {
                    Estatico.servidor.nuevaBase(nombre, new Base.BaseDatos(nombre));
                    Estatico.actualUsuario.agregarPeermiso(nombre);
                }
            }
            else
            {
                if (!(Estatico.servidor.existeBase(nombre)))
                {
                    Estatico.servidor.nuevaBase(nombre, new Base.BaseDatos(nombre));
                    Estatico.actualUsuario.agregarPeermiso(nombre);
                }
                else
                {
                    Estatico.errores.Add(new ErrorCQL("Ejecucion", "Base de datos: " + nombre + " ya existe ", this.fila, this.columna));
                }
            }

            return(null);
        }
コード例 #8
0
        public object getValor(Entorno.Entorno ent)
        {
            DateTime localDate = DateTime.Now;
            int      hora      = localDate.Hour;
            int      minutos   = localDate.Minute;
            int      segundos  = localDate.Second;

            String hora_2 = hora.ToString() + ":";

            if (minutos < 10)
            {
                hora_2 += "0";
            }
            hora_2 += minutos + ":";

            if (segundos < 10)
            {
                hora_2 += "0";
            }
            hora_2 += segundos;

            Tiempo nuevo = new Tiempo(hora_2);

            return(nuevo);
        }
コード例 #9
0
ファイル: Poner.cs プロジェクト: DouglasAC/Proyecto01Compi2
        public object getValor(Entorno.Entorno ent)
        {
            if (coleccion != null)
            {
                if (coleccion is Lista)
                {
                    Lista l = (Lista)coleccion;

                    Object valpos = posicion.getValor(ent);
                    if (valpos is int)
                    {
                        Object val     = valor.getValor(ent);
                        Tipo   tipo    = valor.getTipo(ent);
                        bool   ingreso = l.setElemento((int)valpos, val, tipo);
                        if (!ingreso)
                        {
                            Estatico.errores.Add(new ErrorCQL("Semantico", "Error en set en la lista", this.fila, this.columna));
                        }
                    }
                    else
                    {
                        Estatico.errores.Add(new ErrorCQL("Semantico", "Error el indice debe de ser int ", this.fila, this.columna));
                    }
                }
                else if (coleccion is Map)
                {
                    Map    l       = (Map)coleccion;
                    Object valpos  = posicion.getValor(ent);
                    Tipo   tclave  = posicion.getTipo(ent);
                    Object val     = valor.getValor(ent);
                    Tipo   tipo    = valor.getTipo(ent);
                    bool   ingreso = l.setElemento(tipo, val, tclave, valpos);
                    if (!ingreso)
                    {
                        Estatico.errores.Add(new ErrorCQL("Semantico", "Error en set en del map", this.fila, this.columna));
                    }
                }
                else if (coleccion is Set)
                {
                    Set    l      = (Set)coleccion;
                    Object valpos = posicion.getValor(ent);
                    if (valpos is int)
                    {
                        Object val     = valor.getValor(ent);
                        Tipo   tipo    = valor.getTipo(ent);
                        bool   ingreso = l.setElemento((int)valpos, val, tipo);
                        if (!ingreso)
                        {
                            Estatico.errores.Add(new ErrorCQL("Semantico", "Error en set en tipo SET", this.fila, this.columna));
                        }
                    }
                    else
                    {
                        Estatico.errores.Add(new ErrorCQL("Semantico", "Error el indice debe de ser int ", this.fila, this.columna));
                    }
                }
            }
            return(null);
        }
コード例 #10
0
ファイル: getYear.cs プロジェクト: DouglasAC/Proyecto01Compi2
 public Tipo getTipo(Entorno.Entorno ent)
 {
     if (fecha is Date)
     {
         return(new Tipo("int"));
     }
     return(new Tipo("null"));
 }
コード例 #11
0
 public Tipo getTipo(Entorno.Entorno ent)
 {
     if (hora is Tiempo)
     {
         return(new Tipo("int"));
     }
     return(new Tipo("null"));
 }
コード例 #12
0
ファイル: toUpper.cs プロジェクト: DouglasAC/Proyecto01Compi2
 public Tipo getTipo(Entorno.Entorno ent)
 {
     if (cadena is String)
     {
         return(new Tipo("string"));
     }
     return(new Tipo("null"));
 }
コード例 #13
0
 public object getValor(Entorno.Entorno ent)
 {
     if (Estatico.actualBase != null)
     {
         if (Estatico.actualBase.existeObjetoDefinido(tipo.tipo))
         {
             if (!valores)
             {
                 ObjetoDefinido  declarar  = Estatico.actualBase.GetObjetoDefinido(tipo.tipo);
                 Entorno.Entorno atributos = new Entorno.Entorno(null);
                 foreach (Declaracion declaracion in declarar.declaraciones)
                 {
                     declaracion.ejecutar(atributos);
                 }
                 Objeto ob = new Objeto(tipo, tipo.tipo, atributos);
                 //ob.imprimirAtributos();
                 return(ob);
             }
             else
             {
                 //Console.Write("entro aaaaaaaaaaaaaa");
                 ObjetoDefinido declarar = Estatico.actualBase.GetObjetoDefinido(tipo.tipo);
                 if (declarar.declaraciones.Count == valores_obejeto.Count)
                 {
                     Entorno.Entorno atributos = new Entorno.Entorno(ent);
                     int             x         = 0;
                     foreach (Declaracion declaracion in declarar.declaraciones)
                     {
                         declaracion.valorInicial = valores_obejeto.ElementAt(x);
                         declaracion.ejecutar(atributos);
                         x++;
                     }
                     Entorno.Entorno atributos2 = new Entorno.Entorno(null);
                     atributos2.tabla = atributos.tabla;
                     Objeto ob = new Objeto(tipo, tipo.tipo, atributos2);
                     ob.imprimirAtributos();
                     //atributos.imprimir();
                     return(ob);
                 }
                 else
                 {
                     Estatico.errores.Add(new ErrorCQL("Ejecucion", "Faltan valores en el objeto: " + tipo.tipo + " en la base: " + Estatico.actualBase.nombre, this.fila, this.columna));
                 }
             }
         }
         else
         {
             Estatico.errores.Add(new ErrorCQL("Ejecucion", "No existe el objeto: " + tipo.tipo + " 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(new Nulo());
 }
コード例 #14
0
ファイル: Log.cs プロジェクト: DouglasAC/Proyecto01Compi2
        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);
        }
コード例 #15
0
        public object ejecutar(Entorno.Entorno ent)
        {
            Entorno.Entorno local  = new Entorno.Entorno(ent);
            object          inicio = this.inicializacion.ejecutar(local);

            while ((Boolean)this.condicion.getValor(local))
            {
                Entorno.Entorno local2 = new Entorno.Entorno(local);
                foreach (NodoAST nodo in this.sentencias)
                {
                    if (nodo is Instruccion)
                    {
                        Instruccion ins    = (Instruccion)nodo;
                        Object      result = ins.ejecutar(local);

                        if (result != null)
                        {
                            if (result is Break)
                            {
                                return(null);
                            }
                            else if (result is Continue)
                            {
                                goto siguiente;
                            }
                            else
                            {
                                return(result);
                            }
                        }
                    }
                    else if (nodo is Expresion)
                    {
                        Expresion expr = (Expresion)nodo;
                        Object    ret  = expr.getValor(local);
                        if (ret is Return)
                        {
                            return(ret);
                        }
                    }
                }
siguiente:
                if (actualizacion is Instruccion)
                {
                    Instruccion act    = (Instruccion)this.actualizacion;
                    Object      valact = act.ejecutar(local);
                }
                else if (actualizacion is Expresion)
                {
                    Expresion act    = (Expresion)this.actualizacion;
                    Object    valact = act.getValor(local);
                }
            }
            return(null);
        }
コード例 #16
0
        public object getValor(Entorno.Entorno ent)
        {
            if (contenido == null)
            {
                return(new Map(tipo_clave, tipo_valor));
            }
            else
            {
                NodoExpresionMapa primero = contenido.First();
                Tipo tipo_primero         = primero.clava.getTipo(ent);
                bool todos_igual          = true;
                foreach (NodoExpresionMapa exp in contenido)
                {
                    Tipo exp_tipo = exp.clava.getTipo(ent);
                    if (!tipo_primero.tipo.Equals(exp_tipo.tipo))
                    {
                        todos_igual = false;
                    }
                }
                Tipo tipo_primero_valor = primero.valor.getTipo(ent);
                bool todos_igual_valor  = true;
                foreach (NodoExpresionMapa exp in contenido)
                {
                    Tipo exp_tipo = exp.valor.getTipo(ent);
                    if (!tipo_primero_valor.tipo.Equals(exp_tipo.tipo))
                    {
                        todos_igual_valor = false;
                    }
                }
                if (todos_igual && todos_igual_valor)
                {
                    Map nuevo = new Map(tipo_primero, tipo_primero_valor);

                    foreach (NodoExpresionMapa exp in contenido)
                    {
                        Object exp_clave      = exp.clava.getValor(ent);
                        Object exp_valor      = exp.valor.getValor(ent);
                        Tipo   exp_tipo_clave = exp.clava.getTipo(ent);
                        Tipo   exp_tipo_valor = exp.valor.getTipo(ent);
                        bool   inserto        = nuevo.insertar(exp_tipo_valor, exp_valor, exp_tipo_clave, exp_clave);
                        if (!inserto)
                        {
                            Estatico.errores.Add(new ErrorCQL("Semantico", "Error valor repetido en el map ", this.fila, this.columna));
                        }
                    }
                    return(nuevo);
                }
                else
                {
                    Estatico.errores.Add(new ErrorCQL("Semantico", "Error de tipos en el map no todos son del mismo tipo ", this.fila, this.columna));
                }
            }
            return(null);
        }
コード例 #17
0
        public Tipo getTipo(Entorno.Entorno ent)
        {
            Object val = this.getValor(ent);

            if (val is int)
            {
                return(new Tipo("int"));
            }

            return(new Tipo("null"));
        }
コード例 #18
0
        public object getValor(Entorno.Entorno ent)
        {
            Simbolo aux = ent.get(this.identificador.ToLower());

            if (aux is Objeto)
            {
                Objeto axus = (Objeto)aux;
                return(axus);
            }
            return(aux != null ? aux.valor : null);
        }
コード例 #19
0
        public Tipo getTipo(Entorno.Entorno ent)
        {
            Object val = getValor(ent);

            if (val is Objeto)
            {
                Objeto obj = (Objeto)val;
                return(obj.tipo);
            }
            return(new Tipo("null"));
        }
コード例 #20
0
ファイル: getYear.cs プロジェクト: DouglasAC/Proyecto01Compi2
 public object getValor(Entorno.Entorno ent)
 {
     if (fecha is Date)
     {
         return(((Date)fecha).year);
     }
     else
     {
         Estatico.errores.Add(new ErrorCQL("Semantico", "Error getYeat debe de ser date ", this.fila, this.columna));
     }
     return(null);
 }
コード例 #21
0
 public object ejecutar(Entorno.Entorno ent)
 {
     if (Estatico.servidor.existeBase(nombre))
     {
         Estatico.servidor.eliminarBase(nombre);
     }
     else
     {
         Estatico.errores.Add(new ErrorCQL("Ejecucion", "Base de datos: " + nombre + " no ya existe ", this.fila, this.columna));
     }
     return(null);
 }
コード例 #22
0
 public object ejecutar(Entorno.Entorno ent)
 {
     if (!Estatico.servidor.existeUsuario(nombre))
     {
         Estatico.servidor.nuevoUsuario(nombre, new Usuario(nombre, clave));
     }
     else
     {
         Estatico.errores.Add(new ErrorCQL("Ejecucion", "El usuario: " + nombre + " ya existe por lo tanto no se puede crear ", this.fila, this.columna));
     }
     return(null);
 }
コード例 #23
0
 public object getValor(Entorno.Entorno ent)
 {
     if (hora is Tiempo)
     {
         return(((Tiempo)hora).hora);
     }
     else
     {
         Estatico.errores.Add(new ErrorCQL("Semantico", "Error getHour debe de ser date ", this.fila, this.columna));
     }
     return(null);
 }
コード例 #24
0
ファイル: toUpper.cs プロジェクト: DouglasAC/Proyecto01Compi2
 public object getValor(Entorno.Entorno ent)
 {
     if (cadena is String)
     {
         return(((String)cadena).ToUpper());
     }
     else
     {
         Estatico.errores.Add(new ErrorCQL("Semantico", "Error toUpperCase debe de ser string ", this.fila, this.columna));
     }
     return(null);
 }
コード例 #25
0
ファイル: Remover.cs プロジェクト: DouglasAC/Proyecto01Compi2
 public object getValor(Entorno.Entorno ent)
 {
     if (coleccion != null)
     {
         if (coleccion is Lista)
         {
             Lista  l   = (Lista)coleccion;
             Object val = valor.getValor(ent);
             if (val is int)
             {
                 Boolean removio = l.remove((int)val);
                 if (!removio)
                 {
                     Estatico.errores.Add(new ErrorCQL("Semantico", "Error no se puedo remover ", this.fila, this.columna));
                 }
             }
             else
             {
                 Estatico.errores.Add(new ErrorCQL("Semantico", "Error el indice debe de ser int ", this.fila, this.columna));
             }
         }
         else if (coleccion is Map)
         {
             Map     l       = (Map)coleccion;
             Object  val     = valor.getValor(ent);
             Tipo    clave   = valor.getTipo(ent);
             Boolean removio = l.remove(clave, val);
             if (!removio)
             {
                 Estatico.errores.Add(new ErrorCQL("Semantico", "Error no se puedo remover ", this.fila, this.columna));
             }
         }
         if (coleccion is Set)
         {
             Set    l   = (Set)coleccion;
             Object val = valor.getValor(ent);
             if (val is int)
             {
                 Boolean removio = l.remove((int)val);
                 if (!removio)
                 {
                     Estatico.errores.Add(new ErrorCQL("Semantico", "Error no se puedo remover ", this.fila, this.columna));
                 }
             }
             else
             {
                 Estatico.errores.Add(new ErrorCQL("Semantico", "Error el indice debe de ser int ", this.fila, this.columna));
             }
         }
     }
     return(null);
 }
コード例 #26
0
        public object ejecutar(Entorno.Entorno ent)
        {
            if (Estatico.actualBase != null)
            {
                if (Estatico.actualBase.existeTabla(nombre_tabla))
                {
                    Tabla actual       = Estatico.actualBase.getTabla(nombre_tabla);
                    bool  todosexisten = true;
                    foreach (String columna in this.columnas_eliminar)
                    {
                        if (!actual.existeColumna(columna))
                        {
                            todosexisten = false;
                            Estatico.errores.Add(new ErrorCQL("Ejecucion", "En la tabla: " + nombre_tabla + ", no existe en la columna: " + columna + " por lo tanto no se puede eliminar", this.fila, this.columna));
                        }
                    }

                    if (todosexisten)
                    {
                        bool noprimarias = true;
                        foreach (String columna in this.columnas_eliminar)
                        {
                            if (actual.esPrimaria(columna))
                            {
                                noprimarias = false;
                                Estatico.errores.Add(new ErrorCQL("Ejecucion", "En la tabla: " + nombre_tabla + ", la columna: " + columna + ", es llave primaria por lo tanto no se puede eliminar", this.fila, this.columna));
                            }
                        }
                        if (noprimarias)
                        {
                            foreach (String columna in this.columnas_eliminar)
                            {
                                actual.eliminarColumna(columna);
                            }
                        }
                    }

                    //Estatico.actualBase.getTabla(nombre_tabla).imprimirTabla();
                    //Estatico.actualBase.getTabla(nombre_tabla).imprimirCountColumnas();
                }
                else
                {
                    Estatico.errores.Add(new ErrorCQL("Ejecucion", "La tabla: " + nombre_tabla + " no existe en la base: " + Estatico.actualBase.nombre, this.fila, this.columna));
                }
            }
            else
            {
                Estatico.errores.Add(new ErrorCQL("Ejecucion", "No hay base de datos seleccionada ", this.fila, this.columna));
            }

            return(null);
        }
コード例 #27
0
ファイル: Return.cs プロジェクト: DouglasAC/Proyecto01Compi2
        public Tipo getTipo(Entorno.Entorno ent)
        {
            if (valor != null)
            {
                return(valor.getTipo(ent));
            }
            else if (valores != null)
            {
                return(new Tipo("procedure"));
            }

            return(new Tipo("nulo"));
        }
コード例 #28
0
        public Tipo getTipo(Entorno.Entorno ent)
        {
            Object valor = this.getValor(ent);

            if (valor is Boolean)
            {
                return(new Tipo("bool"));
            }
            else if (valor is String)
            {
                return(new Tipo("string"));
            }
            else if (valor is int)
            {
                return(new Tipo("int"));
            }
            else if (valor is double)
            {
                return(new Tipo("double"));
            }
            else if (valor is Date)
            {
                return(new Tipo("date"));
            }
            else if (valor is Tiempo)
            {
                return(new Tipo("time"));
            }
            else if (valor is Lista)
            {
                return(new Tipo("list"));
            }
            else if (valor is Map)
            {
                return(new Tipo("map"));
            }
            else if (valor is Set)
            {
                return(new Tipo("set"));
            }
            else if (valor is Objeto)
            {
                Objeto obj = (Objeto)valor;
                return(obj.tipo);
            }
            else
            {
                return(new Tipo("null"));
            }
        }
コード例 #29
0
        public object ejecutar(Entorno.Entorno ent)
        {
            Object condicion_while = this.condicion.getValor(ent);

            if (condicion_while is Boolean)
            {
                do
                {
                    Entorno.Entorno local = new Entorno.Entorno(ent);
                    foreach (NodoAST nodo in this.sentencias)
                    {
                        if (nodo is Instruccion)
                        {
                            Instruccion ins = (Instruccion)nodo;

                            Object result = ins.ejecutar(local);
                            if (result != null)
                            {
                                if (result is Break)
                                {
                                    return(null);
                                }
                                else if (result is Continue)
                                {
                                    break;
                                }
                                else
                                {
                                    return(result);
                                }
                            }
                        }
                        else if (nodo is Expresion)
                        {
                            Expresion expr = (Expresion)nodo;
                            Object    ret  = expr.getValor(local);
                            if (ret is Return)
                            {
                                return(ret);
                            }
                        }
                    }
                } while ((Boolean)this.condicion.getValor(ent));
            }
            else
            {
                Estatico.errores.Add(new ErrorCQL("Semantico", "La expresion del Do_While no es booleana ", fila, columna));
            }
            return(null);
        }
コード例 #30
0
        public Tipo getTipo(Entorno.Entorno ent)
        {
            Simbolo sm    = ent.get(variable);
            Object  valor = sm.valor;

            if (valor is int)
            {
                return(new Tipo("int"));
            }
            else if (valor is double)
            {
                return(new Tipo("double"));
            }
            return(new Tipo("null"));
        }