Beispiel #1
0
        public bool Castear(Tipo t, Entorno e, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            foreach (CollectionValue value in Valores)
            {
                if (Tipo.IsMap())
                {
                    if (!Tipo.Clave.Equals(t.Clave))
                    {
                        Casteo castClave = new Casteo(t.Clave, new Literal(Tipo.Clave, value.Clave, 0, 0), 0, 0)
                        {
                            Mostrar = false
                        };

                        object valorCastClave = castClave.GetValor(e, log, errores);

                        if (valorCastClave != null)
                        {
                            if (valorCastClave is Throw)
                            {
                                return(false);
                            }

                            value.Clave = valorCastClave;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                if (!Tipo.Valor.Equals(t.Valor))
                {
                    Casteo cast = new Casteo(t.Valor, new Literal(Tipo.Valor, value.Valor, 0, 0), 0, 0)
                    {
                        Mostrar = false
                    };

                    object valorCast = cast.GetValor(e, log, errores);

                    if (valorCast != null)
                    {
                        if (valorCast is Throw)
                        {
                            return(false);
                        }

                        value.Valor = valorCast;
                        continue;
                    }
                    return(false);
                }
            }
            Tipo = t;
            return(true);
        }
Beispiel #2
0
        public void Ejecutar(Entorno e)
        {
            Simbolo simb = e.Obtener(id);

            if (simb == null)
            {
                Console.WriteLine("No se puede asigar un valor al identificador " + id + " ya que no se encuentra en este entorno");
                return;
            }
            //Si encontramos el simbolo validamos tipos
            Tipos  tipo_asignacion = simb.tipo;
            Tipos  tipo_a_asignar  = valor.GetTipo(e);
            object val             = valor.GetValor(e);

            if (!tipo_asignacion.Equals(tipo_a_asignar))
            {
                //Intento realizar un casteo
                Casteo cast      = new Casteo(tipo_asignacion, tipo_a_asignar, val);
                Tipos  tipoNuevo = cast.GetTipo(e);
                if (!tipoNuevo.Equals(Tipos.NULL))
                {
                    object nuevoValor = cast.GetValor(e);
                    if (nuevoValor == null)
                    {
                        Console.WriteLine("Ocurrio un error al ejecutar el cast");
                        return;
                    }
                    //Si se obtuvo un valor valido del cast
                    simb.valor = nuevoValor;
                }
                //Si no se puede realizar el casteo
                else
                {
                    Console.WriteLine("No se puede asigar un tipo " + tipo_a_asignar + " al identificador " + id + " de tipo " + tipo_asignacion);
                }
                return;
            }
            //Si los tipos son iguales
            if (val == null)
            {
                Console.WriteLine("No se realizo la asignacion al identificador " + id + " ya que al calcular el valor de su expresion retorno null");
                return;
            }
            //Si se capturo un valor valido
            if (simb is Objeto objeto && val is Entorno atributos)
            {
                objeto.atributos = atributos;
                return;
            }
            if (simb is ListCollection list && val is List <object> valores)
            {
                list.valores = valores;
                return;
            }
            simb.valor = val;
        }
Beispiel #3
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            BD actual = e.Master.Actual;

            if (actual != null)
            {
                if (e.Master.UsuarioActual != null)
                {
                    if (e.Master.UsuarioActual.GetPermiso(actual.Id))
                    {
                        Simbolo sim = actual.GetTabla(Id);

                        if (sim != null)
                        {
                            Tabla tabla = (Tabla)sim.Valor;

                            if (Columnas != null)
                            {
                                if (Columnas.Count() == Valores.Count())
                                {
                                    Entorno datos = tabla.GetNuevaFila();
                                    LinkedList <Simbolo> primary = new LinkedList <Simbolo>();

                                    for (int i = 0; i < Columnas.Count(); i++)
                                    {
                                        Expresion valor    = Valores.ElementAt(i);
                                        object    valValor = valor.GetValor(e, log, errores);
                                        if (valValor != null)
                                        {
                                            if (valValor is Throw)
                                            {
                                                return(valValor);
                                            }

                                            string  col  = Columnas.ElementAt(i);
                                            Simbolo dato = datos.GetCualquiera(col);
                                            if (dato != null)
                                            {
                                                if (dato.Tipo.IsCounter())
                                                {
                                                    return(new Throw("CounterTypeException", Linea, Columna));
                                                    //dato.Valor = tabla.Contador;
                                                    //continue;
                                                }

                                                if (dato.Tipo.Equals(valor.Tipo))
                                                {
                                                    dato.Valor = valValor;

                                                    if (dato.Rol == Rol.PRIMARY)
                                                    {
                                                        if (valValor is Null)
                                                        {
                                                            errores.AddLast(new Error("Semántico", "Una llave primaria no puede ser Null.", Linea, Columna));
                                                            return(null);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    Casteo cast = new Casteo(dato.Tipo, new Literal(valor.Tipo, valValor, 0, 0), 0, 0)
                                                    {
                                                        Mostrar = false
                                                    };
                                                    valValor = cast.GetValor(e, log, errores);

                                                    if (valValor != null)
                                                    {
                                                        if (valValor is Throw)
                                                        {
                                                            return(valValor);
                                                        }

                                                        dato.Valor = valValor;
                                                        continue;
                                                    }

                                                    return(new Throw("ValuesException", Linea, Columna));
                                                    //errores.AddLast(new Error("Semántico", "El tipo de la expresión no corresponde al tipo en la columna: " + sim.Id + ".", Linea, Columna));
                                                    //return null;
                                                }
                                            }
                                            else
                                            {
                                                errores.AddLast(new Error("Semántico", "No hay un campo con el id: " + col + " en la Tabla.", Linea, Columna));
                                                return(null);
                                            }
                                        }
                                        else
                                        {
                                            return(null);
                                        }
                                    }

                                    foreach (Simbolo col in datos.Simbolos)
                                    {
                                        if (col.Tipo.IsCounter())
                                        {
                                            col.Valor = tabla.Contador;
                                        }

                                        if (col.Rol == Rol.PRIMARY)
                                        {
                                            if (col.Valor is Null)
                                            {
                                                errores.AddLast(new Error("Semántico", "Una llave primaria no puede ser Null.", Linea, Columna));
                                                return(null);
                                            }
                                            primary.AddLast(col);
                                        }
                                    }


                                    if (!tabla.Insertar(datos, primary))
                                    {
                                        errores.AddLast(new Error("Semántico", "No se pueden insertar valores con la misma llave primaria.", Linea, Columna));
                                    }
                                    else
                                    {
                                        tabla.Contador++;
                                        Correcto = true;
                                    }

                                    return(null);
                                }
                                else
                                {
                                    errores.AddLast(new Error("Semántico", "La lista de campos no corresponde a la lista de valores.", Linea, Columna));
                                }
                            }
                            else
                            {
                                if (tabla.Cabecera.Simbolos.Count() == Valores.Count())
                                {
                                    Entorno datos = new Entorno(null, new LinkedList <Simbolo>());
                                    LinkedList <Simbolo> primary = new LinkedList <Simbolo>();

                                    for (int i = 0; i < Valores.Count(); i++)
                                    {
                                        Expresion valor    = Valores.ElementAt(i);
                                        object    valValor = valor.GetValor(e, log, errores);
                                        if (valValor != null)
                                        {
                                            if (valValor is Throw)
                                            {
                                                return(valValor);
                                            }

                                            Simbolo col = tabla.Cabecera.Simbolos.ElementAt(i);

                                            if (col.Tipo.IsCounter())
                                            {
                                                return(new Throw("CounterTypeException", Linea, Columna));
                                                //errores.AddLast(new Error("Semántico", "No se puede insertar un valor en una columna tipo Counter.", Linea, Columna));
                                                //return null;
                                            }

                                            if (!col.Tipo.Equals(valor.Tipo))
                                            {
                                                Casteo cast = new Casteo(col.Tipo, new Literal(valor.Tipo, valValor, 0, 0), 0, 0)
                                                {
                                                    Mostrar = false
                                                };
                                                valValor = cast.GetValor(e, log, errores);

                                                if (valValor == null)
                                                {
                                                    if (valValor is Throw)
                                                    {
                                                        return(valValor);
                                                    }

                                                    return(new Throw("ValuesException", Linea, Columna));
                                                    //errores.AddLast(new Error("Semántico", "El tipo de la expresión no corresponde al tipo en la columna: " + col.Id + ".", Linea, Columna));
                                                    //return null;
                                                }
                                            }

                                            Simbolo dato = new Simbolo(col.Tipo, col.Rol, col.Id, valValor);
                                            if (col.Rol == Rol.PRIMARY)
                                            {
                                                if (valValor is Null)
                                                {
                                                    errores.AddLast(new Error("Semántico", "Una llave primaria no puede ser Null.", Linea, Columna));
                                                    return(null);
                                                }
                                                primary.AddLast(dato);
                                            }
                                            datos.Add(dato);
                                        }
                                        else
                                        {
                                            return(null);
                                        }
                                    }

                                    if (!tabla.Insertar(datos, primary))
                                    {
                                        errores.AddLast(new Error("Semántico", "No se pueden insertar valores con la misma llave primaria.", Linea, Columna));
                                    }
                                    else
                                    {
                                        Correcto = true;
                                    }
                                    return(null);
                                }
                                else
                                {
                                    return(new Throw("ValuesException", Linea, Columna));
                                }
                                //errores.AddLast(new Error("Semántico", "Los valores no corresponden a las columnas en la Tabla.", Linea, Columna));
                            }
                        }
                        else
                        {
                            return(new Throw("TableDontExists", Linea, Columna));
                        }
                        //errores.AddLast(new Error("Semántico", "No existe una Tabla con el id: " + Id + " en la base de datos.", Linea, Columna));
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "El Usuario no tiene permisos sobre: " + actual.Id + ".", Linea, Columna));
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "No hay un Usuario logeado.", Linea, Columna));
                }
            }
            else
            {
                return(new Throw("UseBDException", Linea, Columna));
            }
            //errores.AddLast(new Error("Semántico", "No se ha seleccionado una base de datos, no se pudo Insertar.", Linea, Columna));

            return(null);
        }
Beispiel #4
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            BD actual = e.Master.Actual;

            if (actual != null)
            {
                Simbolo sim = actual.GetTabla(Id);

                if (sim != null)
                {
                    Tabla tabla = (Tabla)sim.Valor;

                    if (Where == null)
                    {
                        tabla.Datos.Clear();
                    }
                    else
                    {
                        LinkedList <Entorno> delete = new LinkedList <Entorno>();

                        foreach (Entorno ent in tabla.Datos)
                        {
                            e.Master.EntornoActual = ent;

                            object valWhere = Where.GetValor(e, log, errores);
                            if (valWhere != null)
                            {
                                if (valWhere is Throw)
                                {
                                    return(valWhere);
                                }

                                if (Where.Tipo.IsBoolean())
                                {
                                    if (!(bool)valWhere)
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    errores.AddLast(new Error("Semántico", "Cláusula Where debe ser booleana.", Linea, Columna));
                                    return(null);
                                }
                            }
                            else
                            {
                                return(null);
                            }

                            if (Target == null)
                            {
                                delete.AddLast(ent);
                            }
                            else
                            {
                                if (Target is Acceso acc)
                                {
                                    object valorTarget = acc.Target.GetValor(e, log, errores);

                                    if (valorTarget != null)
                                    {
                                        if (valorTarget is Throw)
                                        {
                                            return(valorTarget);
                                        }

                                        if (acc.Target.Tipo.IsCollection())
                                        {
                                            if (valorTarget is Null)
                                            {
                                                return(new Throw("NullPointerException", Linea, Columna));
                                            }
                                            else
                                            {
                                                Collection collection = (Collection)valorTarget;

                                                object valExpr = acc.Expr.GetValor(e, log, errores);

                                                if (valExpr != null)
                                                {
                                                    if (valExpr is Throw)
                                                    {
                                                        return(valExpr);
                                                    }

                                                    if (!collection.Tipo.Clave.Equals(acc.Expr.Tipo))
                                                    {
                                                        Casteo cast = new Casteo(collection.Tipo.Clave, new Literal(acc.Expr.Tipo, valExpr, 0, 0), 0, 0)
                                                        {
                                                            Mostrar = false
                                                        };
                                                        valExpr = cast.GetValor(e, log, errores);

                                                        if (valExpr == null)
                                                        {
                                                            errores.AddLast(new Error("Semántico", "El tipo de la clave no coincide con el declarado en el Collection: " + collection.Tipo.Clave.Type.ToString() + ".", Linea, Columna));
                                                            continue;
                                                        }
                                                        else
                                                        {
                                                            if (valExpr is Throw)
                                                            {
                                                                return(valExpr);
                                                            }
                                                        }
                                                    }

                                                    if (acc.Target.Tipo.IsList())
                                                    {
                                                        if (!collection.RemoveList(valExpr))
                                                        {
                                                            return(new Throw("IndexOutException", Linea, Columna));
                                                        }
                                                    }
                                                    else if (acc.Target.Tipo.IsSet())
                                                    {
                                                        if (collection.Remove(valExpr))
                                                        {
                                                            collection.Ordenar();
                                                        }
                                                        else
                                                        {
                                                            return(new Throw("IndexOutException", Linea, Columna));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (!collection.Remove(valExpr))
                                                        {
                                                            errores.AddLast(new Error("Semántico", "No existe un valor con la clave: " + valExpr.ToString() + " en Map.", Linea, Columna));
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        errores.AddLast(new Error("Semántico", "La variable debe ser de tipo Map, List o Set.", Linea, Columna));
                                    }
                                }
                            }
                        }

                        e.Master.EntornoActual = null;

                        foreach (Entorno ent in delete)
                        {
                            tabla.Datos.Remove(ent);
                        }
                    }
                    Correcto = true;
                    return(null);
                }
                else
                {
                    return(new Throw("TableDontExists", Linea, Columna));
                }
                //errores.AddLast(new Error("Semántico", "No existe una Tabla con el id: " + Id + " en la base de datos.", Linea, Columna));
            }
            else
            {
                return(new Throw("UseBDException", Linea, Columna));
            }
            //errores.AddLast(new Error("Semántico", "No se ha seleccionado una base de datos, no se pudo Eliminar.", Linea, Columna));
        }
Beispiel #5
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            object obj = Call.GetSimbolo(e, log, errores);

            if (obj == null)
            {
                return(null);
            }

            if (obj is Throw)
            {
                return(obj);
            }

            Simbolo sim = (Simbolo)obj;

            Procedimiento proc = (Procedimiento)sim.Valor;

            if (proc.Retorno != null)
            {
                if (proc.Retorno.Count() == Target.Count())
                {
                    obj = Call.GetValor(e, log, errores);

                    if (obj != null)
                    {
                        if (obj is Throw)
                        {
                            return(obj);
                        }

                        LinkedList <Literal> valores = (LinkedList <Literal>)obj;

                        for (int i = 0; i < Target.Count(); i++)
                        {
                            Expresion target = Target.ElementAt(i);
                            Literal   valor  = valores.ElementAt(i);

                            if (target is Identificador iden)
                            {
                                Simbolo simIden = iden.GetSimbolo(e);

                                if (simIden != null)
                                {
                                    if (valor.Tipo.IsNull())
                                    {
                                        if (simIden.Tipo.IsNullable())
                                        {
                                            simIden.Valor = valor.Valor;
                                            continue;
                                        }
                                    }

                                    if (simIden.Tipo.Equals(valor.Tipo))
                                    {
                                        simIden.Valor = valor.Valor;
                                    }
                                    else
                                    {
                                        Casteo cast = new Casteo(simIden.Tipo, valor, 0, 0)
                                        {
                                            Mostrar = false
                                        };

                                        object valExpr = cast.GetValor(e, log, errores);

                                        if (valExpr != null)
                                        {
                                            if (valExpr is Throw)
                                            {
                                                return(valExpr);
                                            }

                                            simIden.Valor = valExpr;
                                        }
                                        else
                                        {
                                            errores.AddLast(new Error("Semántico", "El tipo del Return no coincide con el de la variable: " + target.GetId() + ".", Linea, Columna));
                                        }
                                    }
                                }
                                else
                                {
                                    errores.AddLast(new Error("Semántico", "No se ha declarado una variable con el id: " + target.GetId() + ".", Linea, Columna));
                                }
                            }
                            else
                            {
                                errores.AddLast(new Error("Semántico", "Solo se pueden capturar el Return en variables.", Linea, Columna));
                            }
                        }
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "Los valores que retorna el Procedimiento no coinciden con la asignación.", Linea, Columna));
                }
            }
            else
            {
                errores.AddLast(new Error("Semántico", "El procedimiento no retorna valores.", Linea, Columna));
            }

            return(null);
        }
Beispiel #6
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            BD actual = e.Master.Actual;

            if (actual != null)
            {
                if (e.Master.UsuarioActual != null)
                {
                    if (e.Master.UsuarioActual.GetPermiso(actual.Id))
                    {
                        Simbolo sim = actual.GetTabla(Id);

                        if (sim != null)
                        {
                            Tabla tabla = (Tabla)sim.Valor;

                            LinkedList <Entorno> datos = new LinkedList <Entorno>();

                            if (Order != null)
                            {
                                if (tabla.Datos.Count() > 1)
                                {
                                    foreach (Entorno ent in tabla.Datos)
                                    {
                                        Entorno entActual = new Entorno(null, new LinkedList <Simbolo>());

                                        foreach (Simbolo simActual in ent.Simbolos)
                                        {
                                            entActual.Add(new Simbolo(simActual.Tipo, simActual.Rol, simActual.Id, simActual.Valor));
                                        }

                                        datos.AddLast(entActual);
                                    }

                                    e.Master.EntornoActual = tabla.Datos.ElementAt(0);

                                    if (Order.Count() >= 1)
                                    {
                                        for (int j = Order.Count() - 1; j >= 0; j--)
                                        {
                                            Identificador ident = Order.ElementAt(j);

                                            LinkedList <Entorno>  tmp = new LinkedList <Entorno>();
                                            IEnumerable <Entorno> ordered;

                                            object identValor = ident.GetValor(e, log, errores);

                                            if (identValor != null)
                                            {
                                                if (identValor is Throw)
                                                {
                                                    return(identValor);
                                                }

                                                if (ident.Tipo.IsString() || ident.Tipo.IsDate() || ident.Tipo.IsTime())
                                                {
                                                    ordered = datos.OrderBy(p => p.GetCualquiera(ident.GetId()).Valor.ToString()).AsEnumerable();
                                                }
                                                else if (ident.Tipo.IsInt())
                                                {
                                                    ordered = datos.OrderBy(p => (int)p.GetCualquiera(ident.GetId()).Valor).AsEnumerable();
                                                }
                                                else if (ident.Tipo.IsDouble())
                                                {
                                                    ordered = datos.OrderBy(p => (double)p.GetCualquiera(ident.GetId()).Valor).AsEnumerable();
                                                }
                                                else
                                                {
                                                    errores.AddLast(new Error("Semántico", "Solo se puede usar la cláusula Order By sobre datos primitivos.", Linea, Columna));
                                                    return(null);
                                                }

                                                if (ident.IsASC)
                                                {
                                                    foreach (Entorno eTmp in ordered)
                                                    {
                                                        tmp.AddLast(eTmp);
                                                    }
                                                }
                                                else
                                                {
                                                    for (int i = ordered.Count() - 1; i >= 0; i--)
                                                    {
                                                        tmp.AddLast(ordered.ElementAt(i));
                                                    }
                                                }
                                                datos = tmp;
                                            }
                                            else
                                            {
                                                return(null);
                                            }
                                        }
                                    }

                                    /*
                                     * else if (Order.Count() >= 2)
                                     * {
                                     *  Identificador ident = Order.ElementAt(0);
                                     *  Identificador ident2 = Order.ElementAt(1);
                                     *
                                     *  LinkedList<Entorno> tmp = new LinkedList<Entorno>();
                                     *  IEnumerable<Entorno> ordered;
                                     *
                                     *  object identValor = ident.GetValor(e, log, errores);
                                     *  object identValor2 = ident2.GetValor(e, log, errores);
                                     *
                                     *  if (identValor != null && identValor2 != null)
                                     *  {
                                     *      if (ident.Tipo.IsString() || ident.Tipo.IsDate() || ident.Tipo.IsTime() || ident.Tipo.IsInt() || ident.Tipo.IsDouble())
                                     *          if(ident2.Tipo.IsString() || ident2.Tipo.IsDate() || ident2.Tipo.IsTime() || ident2.Tipo.IsInt() || ident2.Tipo.IsDouble())
                                     *              ordered = datos.OrderBy(p => Tuple.Create(p.GetCualquiera(ident.GetId()).Valor.ToString(), p.GetCualquiera(ident2.GetId()).Valor.ToString()), new ComparaTupla()).AsEnumerable();
                                     *          else
                                     *          {
                                     *              errores.AddLast(new Error("Semántico", "Solo se puede usar la cláusula Order By sobre datos primitivos.", Linea, Columna));
                                     *              return null;
                                     *          }
                                     *      else
                                     *      {
                                     *          errores.AddLast(new Error("Semántico", "Solo se puede usar la cláusula Order By sobre datos primitivos.", Linea, Columna));
                                     *          return null;
                                     *      }
                                     *
                                     *      if (ident.IsASC)
                                     *      {
                                     *          foreach (Entorno eTmp in ordered)
                                     *          {
                                     *              tmp.AddLast(eTmp);
                                     *          }
                                     *      }
                                     *      else
                                     *      {
                                     *          for (int i = ordered.Count() - 1; i >= 0; i--)
                                     *          {
                                     *              tmp.AddLast(ordered.ElementAt(i));
                                     *          }
                                     *      }
                                     *      datos = tmp;
                                     *  }
                                     *  else
                                     *      return null;
                                     * }
                                     */
                                }
                                else
                                {
                                    datos = tabla.Datos;
                                }
                            }
                            else
                            {
                                datos = tabla.Datos;
                            }

                            LinkedList <Entorno> data = new LinkedList <Entorno>();

                            foreach (Entorno ent in datos)
                            {
                                e.Master.EntornoActual = ent;
                                Entorno entActual = new Entorno(null, new LinkedList <Simbolo>());

                                if (Where != null)
                                {
                                    object valWhere = Where.GetValor(e, log, errores);
                                    if (valWhere != null)
                                    {
                                        if (valWhere is Throw)
                                        {
                                            return(valWhere);
                                        }

                                        if (Where.Tipo.IsBoolean())
                                        {
                                            if (!(bool)valWhere)
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            errores.AddLast(new Error("Semántico", "Cláusula Where debe ser booleana.", Linea, Columna));
                                            return(null);
                                        }
                                    }
                                    else
                                    {
                                        return(null);
                                    }
                                }

                                if (Columnas != null)
                                {
                                    int numCol = 1;

                                    foreach (Expresion colExp in Columnas)
                                    {
                                        Simbolo simActual = new Simbolo();

                                        object valColExp = colExp.GetValor(e, log, errores);

                                        if (valColExp != null)
                                        {
                                            if (valColExp is Throw)
                                            {
                                                return(valColExp);
                                            }

                                            simActual.Tipo = colExp.Tipo;
                                            simActual.Rol  = Rol.COLUMNA;

                                            if (colExp is Identificador iden)
                                            {
                                                simActual.Id = iden.GetId().ToLower();
                                            }
                                            else
                                            {
                                                simActual.Id = "columna" + numCol++;
                                            }
                                            simActual.Valor = valColExp;
                                        }
                                        else
                                        {
                                            return(null);
                                        }

                                        entActual.Add(simActual);
                                    }
                                }
                                else
                                {
                                    foreach (Simbolo col in ent.Simbolos)
                                    {
                                        entActual.Add(new Simbolo(col.Tipo, col.Rol, col.Id, col.Valor));
                                    }
                                }

                                data.AddLast(entActual);
                            }

                            e.Master.EntornoActual = null;

                            int limite;

                            if (Limit != null)
                            {
                                object valLimit = Limit.GetValor(e, log, errores);
                                if (valLimit != null)
                                {
                                    if (valLimit is Throw)
                                    {
                                        return(valLimit);
                                    }

                                    if (Limit.Tipo.IsInt())
                                    {
                                        limite = (int)valLimit - 1;

                                        if ((int)valLimit < 0)
                                        {
                                            errores.AddLast(new Error("Semántico", "El Límite debe ser entero positivo.", Linea, Columna));
                                        }
                                    }
                                    else
                                    {
                                        Casteo cast = new Casteo(new Tipo(entorno.Type.INT), new Literal(Limit.Tipo, valLimit, 0, 0), 0, 0)
                                        {
                                            Mostrar = false
                                        };
                                        valLimit = cast.GetValor(e, log, errores);

                                        if (valLimit != null)
                                        {
                                            if (valLimit is Throw)
                                            {
                                                return(valLimit);
                                            }

                                            limite = (int)valLimit - 1;
                                            if ((int)valLimit < 0)
                                            {
                                                errores.AddLast(new Error("Semántico", "El Límite debe ser entero positivo.", Linea, Columna));
                                            }
                                        }
                                        else
                                        {
                                            errores.AddLast(new Error("Semántico", "El Límite debe ser de tipo Entero.", Linea, Columna));
                                            return(null);
                                        }
                                    }
                                }
                                else
                                {
                                    return(null);
                                }
                            }
                            else
                            {
                                limite = data.Count() - 1;
                            }

                            limite = limite > data.Count() - 1 ? data.Count() - 1 : limite;

                            if (Mostrar)
                            {
                                string salida;

                                if (data.Count() >= 1)
                                {
                                    salida  = "<div class=\"table - responsive\">";
                                    salida += "<table class=\"table table-striped table - sm\"> \n";
                                    salida += "<thead>\n";
                                    salida += "<tr> \n";

                                    foreach (Simbolo col in data.ElementAt(0).Simbolos)
                                    {
                                        salida += "\t<th>" + col.Id + "</th>\n";
                                    }

                                    salida += "</tr>\n";
                                    salida += "</thead>\n";
                                    salida += "<tbody>\n";
                                    for (int i = 0; i <= limite; i++)
                                    {
                                        Entorno ent = data.ElementAt(i);
                                        salida += "<tr>\n";

                                        foreach (Simbolo col in ent.Simbolos)
                                        {
                                            salida += "\t<td>" + col.Valor.ToString() + "</td>\n";
                                        }

                                        salida += "</tr>\n";
                                    }
                                    salida += "</tbody>\n";
                                    salida += "</table>\n";
                                    salida += "</div>\n\n";
                                }
                                else
                                {
                                    salida = "No hay datos en la consulta.\n\n";
                                }

                                log.AddLast(new Salida(2, salida));
                                return(null);
                            }
                            else
                            {
                                return(data);
                            }
                        }
                        else
                        {
                            return(new Throw("TableDontExists", Linea, Columna));
                        }
                        //errores.AddLast(new Error("Semántico", "No existe una Tabla con el id: " + Id + " en la base de datos.", Linea, Columna));
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "El Usuario no tiene permisos sobre: " + actual.Id + ".", Linea, Columna));
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "No hay un Usuario logeado.", Linea, Columna));
                }
            }
            else
            {
                return(new Throw("UseBDException", Linea, Columna));
            }
            //errores.AddLast(new Error("Semántico", "No se ha seleccionado una base de datos, no se pudo Actualizar.", Linea, Columna));

            return(null);
        }
Beispiel #7
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            Simbolo sim = e.Get(Id);

            if (sim != null)
            {
                if (sim.Tipo.IsCursor())
                {
                    Cursor cursor = (Cursor)sim.Valor;

                    if (cursor.Data != null)
                    {
                        if (cursor.Data.Count() > 0)
                        {
                            if (Parametro != null)
                            {
                                if (Parametro.Count() == cursor.Data.ElementAt(0).Simbolos.Count())
                                {
                                    foreach (Entorno ent in cursor.Data)
                                    {
                                        Entorno local = new Entorno(e);

                                        for (int i = 0; i < Parametro.Count(); i++)
                                        {
                                            Identificador par = Parametro.ElementAt(i);
                                            Simbolo       col = ent.Simbolos.ElementAt(i);

                                            Simbolo var;

                                            if (par.Tipo.Equals(col.Tipo))
                                            {
                                                var = new Simbolo(par.Tipo, Rol.VARIABLE, par.Id.ToLower(), col.Valor);
                                            }
                                            else
                                            {
                                                /*Agregar Collection*/

                                                Casteo cast = new Casteo(par.Tipo, new Literal(col.Tipo, col.Valor, 0, 0), 0, 0)
                                                {
                                                    Mostrar = false
                                                };
                                                object valCol = cast.GetValor(e, log, errores);

                                                if (valCol != null)
                                                {
                                                    if (valCol is Throw)
                                                    {
                                                        return(valCol);
                                                    }

                                                    var = new Simbolo(par.Tipo, Rol.VARIABLE, par.Id.ToLower(), valCol);
                                                }
                                                else
                                                {
                                                    errores.AddLast(new Error("Semántico", "Los Tipos en los parametros no coinciden con los del Cursor.", Linea, Columna));
                                                    return(null);
                                                }
                                            }
                                            local.Add(var);
                                        }

                                        object obj = Bloque.Ejecutar(local, funcion, true, sw, tc, log, errores);

                                        if (obj is Break)
                                        {
                                            break;
                                        }
                                        else if (obj is Return)
                                        {
                                            return(obj);
                                        }
                                        else if (obj is Throw)
                                        {
                                            return(obj);
                                        }
                                    }
                                    return(null);
                                }
                                else
                                {
                                    errores.AddLast(new Error("Semántico", "Los parametros no coinciden con los del Cursor.", Linea, Columna));
                                }
                            }
                            else
                            {
                                errores.AddLast(new Error("Semántico", "Los parametros no coinciden con los del Cursor.", Linea, Columna));
                            }
                        }
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "El Cursor esta cerrado, ejecute la sentecia Open primero.", Linea, Columna));
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "La variable: " + Id + " no es un cursor.", Linea, Columna));
                }
            }
            return(null);
        }
Beispiel #8
0
        public override object GetValor(Entorno e, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            object valOp1 = Op1.GetValor(e, log, errores);
            object valOp2 = Op2.GetValor(e, log, errores);

            if (valOp1 != null && valOp2 != null)
            {
                if (valOp1 is Throw)
                {
                    return(valOp1);
                }

                if (valOp2 is Throw)
                {
                    return(valOp2);
                }

                TipoDominante(errores);

                if (Tipo != null)
                {
                    switch (Tipo.Type)
                    {
                    case Type.STRING:
                        Cadena cad = new Cadena
                        {
                            Valor = valOp1.ToString() + valOp2.ToString()
                        };
                        return(cad);

                    case Type.DOUBLE:
                        switch (Op)
                        {
                        case Operador.SUMA:
                            return(Convert.ToDouble(valOp1) + Convert.ToDouble(valOp2));

                        case Operador.RESTA:
                            return(Convert.ToDouble(valOp1) - Convert.ToDouble(valOp2));

                        case Operador.MULTIPLICACION:
                            return(Convert.ToDouble(valOp1) * Convert.ToDouble(valOp2));

                        case Operador.POTENCIA:
                            return(Math.Pow(Convert.ToDouble(valOp1), Convert.ToDouble(valOp2)));

                        case Operador.MODULO:
                            return(Convert.ToDouble(valOp1) % Convert.ToDouble(valOp2));

                        case Operador.DIVISION:
                            if (Convert.ToDouble(valOp2) != 0)
                            {
                                return(Convert.ToDouble(valOp1) / Convert.ToDouble(valOp2));
                            }
                            //errores.AddLast(new Error("Semántico", "División entre 0.", Linea, Columna));
                            return(new Throw("ArithmeticException", Linea, Columna));
                        }
                        break;

                    case Type.INT:
                        switch (Op)
                        {
                        case Operador.SUMA:
                            return(Convert.ToInt32(valOp1) + Convert.ToInt32(valOp2));

                        case Operador.RESTA:
                            return(Convert.ToInt32(valOp1) - Convert.ToInt32(valOp2));

                        case Operador.MULTIPLICACION:
                            return(Convert.ToInt32(valOp1) * Convert.ToInt32(valOp2));

                        case Operador.POTENCIA:
                            return(Math.Pow(Convert.ToInt32(valOp1), Convert.ToInt32(valOp2)));

                        case Operador.MODULO:
                            return(Convert.ToInt32(valOp1) % Convert.ToInt32(valOp2));

                        case Operador.DIVISION:
                            if (Convert.ToInt32(valOp2) != 0)
                            {
                                return(Convert.ToInt32(valOp1) / Convert.ToInt32(valOp2));
                            }
                            //errores.AddLast(new Error("Semántico", "División entre 0.", Linea, Columna));
                            return(new Throw("ArithmeticException", Linea, Columna));
                        }
                        break;

                    case Type.MAP:
                        if (valOp1 is Null)
                        {
                            return(new Throw("NullPointerException", Linea, Columna));
                        }
                        if (valOp2 is Null)
                        {
                            return(new Throw("NullPointerException", Linea, Columna));
                        }

                        Collection map1 = (Collection)valOp1;
                        Collection map2 = (Collection)valOp2;

                        foreach (CollectionValue value in map2.Valores)
                        {
                            if (Op == Operador.SUMA)
                            {
                                if (map1.Tipo.Clave.Equals(map2.Tipo.Clave) && map1.Tipo.Valor.Equals(map2.Tipo.Valor))
                                {
                                    if (map1.Get(value.Clave) == null)
                                    {
                                        map1.Insert(value.Clave, value.Valor);
                                    }
                                    else
                                    {
                                        map1.Set(value.Clave, value.Valor);
                                        //errores.AddLast(new Error("Semántico", "Ya existe un valor con la clave: " + value.Clave.ToString() + " en Map.", Linea, Columna));
                                    }
                                }
                                else
                                {
                                    Casteo cast1 = new Casteo(map1.Tipo.Clave, new Literal(map2.Tipo.Clave, value.Clave, 0, 0), 0, 0)
                                    {
                                        Mostrar = false
                                    };

                                    Casteo cast2 = new Casteo(map1.Tipo.Valor, new Literal(map2.Tipo.Valor, value.Valor, 0, 0), 0, 0)
                                    {
                                        Mostrar = false
                                    };

                                    object clave = cast1.GetValor(e, log, errores);
                                    object valor = cast2.GetValor(e, log, errores);

                                    if (clave != null && valor != null)
                                    {
                                        if (clave is Throw)
                                        {
                                            return(clave);
                                        }

                                        if (valor is Throw)
                                        {
                                            return(valor);
                                        }

                                        if (map1.Get(clave) == null)
                                        {
                                            map1.Insert(clave, valor);
                                        }
                                        else
                                        {
                                            map1.Set(clave, valor);
                                            //errores.AddLast(new Error("Semántico", "Ya existe un valor con la clave: " + clave.ToString() + " en Map.", Linea, Columna));
                                        }
                                        continue;
                                    }

                                    errores.AddLast(new Error("Semántico", "Los tipos de los parametros no coinciden con la clave:valor del Map.", Linea, Columna));
                                    return(null);
                                }
                            }
                            else if (Op == Operador.RESTA)
                            {
                                if (map1.Tipo.Clave.Equals(map2.Tipo.Valor))
                                {
                                    if (!map1.Remove(value.Valor))
                                    {
                                        errores.AddLast(new Error("Semántico", "No existe un valor con la clave: " + value.Valor.ToString() + " en Map.", Linea, Columna));
                                    }
                                }
                                else
                                {
                                    Casteo cast = new Casteo(map1.Tipo.Clave, new Literal(map2.Tipo.Valor, value.Valor, 0, 0), 0, 0)
                                    {
                                        Mostrar = false
                                    };

                                    object clave = cast.GetValor(e, log, errores);

                                    if (clave != null)
                                    {
                                        if (!map1.Remove(clave))
                                        {
                                            errores.AddLast(new Error("Semántico", "No existe un valor con la clave: " + clave.ToString() + " en Map.", Linea, Columna));
                                        }
                                    }
                                }
                            }
                            else
                            {
                                return(new Throw("ArithmeticException", Linea, Columna));
                            }
                        }
                        return(map1);

                    case Type.LIST:
                    case Type.SET:
                        if (valOp1 is Null)
                        {
                            return(new Throw("NullPointerException", Linea, Columna));
                        }
                        if (valOp2 is Null)
                        {
                            return(new Throw("NullPointerException", Linea, Columna));
                        }

                        Collection set1 = (Collection)valOp1;
                        Collection set2 = (Collection)valOp2;

                        foreach (CollectionValue value in set2.Valores)
                        {
                            if (Op == Operador.SUMA)
                            {
                                if (set1.Tipo.Valor.Equals(set2.Tipo.Valor))
                                {
                                    set1.Insert(set1.Posicion++, value.Valor);
                                }
                                else
                                {
                                    Casteo cast = new Casteo(set1.Tipo.Valor, new Literal(set2.Tipo.Valor, value.Valor, 0, 0), 0, 0)
                                    {
                                        Mostrar = false
                                    };
                                    object valor = cast.GetValor(e, log, errores);

                                    if (valor != null)
                                    {
                                        if (valor is Throw)
                                        {
                                            return(valor);
                                        }

                                        set1.Insert(set1.Posicion++, valor);
                                        continue;
                                    }

                                    errores.AddLast(new Error("Semántico", "El tipo del parametro no coinciden con el valor de la Collection.", Linea, Columna));
                                    return(null);
                                }
                            }
                            else if (Op == Operador.RESTA)
                            {
                                if (set1.Tipo.Valor.Equals(set2.Tipo.Valor))
                                {
                                    if (!set1.RemoveValor(value.Valor))
                                    {
                                        errores.AddLast(new Error("Semántico", "No existe un valor: " + value.Valor.ToString() + " en Collection.", Linea, Columna));
                                    }
                                }
                                else
                                {
                                    Casteo cast = new Casteo(set1.Tipo.Valor, new Literal(set2.Tipo.Valor, value.Valor, 0, 0), 0, 0)
                                    {
                                        Mostrar = false
                                    };
                                    object valor = cast.GetValor(e, log, errores);

                                    if (valor != null)
                                    {
                                        if (valor is Throw)
                                        {
                                            return(valor);
                                        }

                                        if (!set1.RemoveValor(valor))
                                        {
                                            errores.AddLast(new Error("Semántico", "No existe un valor: " + valor.ToString() + " en Collection.", Linea, Columna));
                                        }

                                        continue;
                                    }

                                    errores.AddLast(new Error("Semántico", "El tipo del parametro no coinciden con el valor de la Collection.", Linea, Columna));
                                    return(null);
                                }
                            }
                            else
                            {
                                return(new Throw("ArithmeticException", Linea, Columna));
                            }
                        }

                        return(set1);
                    }
                }
                return(new Throw("ArithmeticException", Linea, Columna));
            }

            return(null);
        }
Beispiel #9
0
        public void Ejecutar(Entorno e)
        {
            //Adicion de identificadores al entorno
            foreach (string identificador in identificadores)
            {
                e.Insertar(new Simbolo(identificador, tipo));
            }
            if (asignacion == null)
            {
                return;
            }

            //Si es una asignacion
            string  id = identificadores.Last.Value;
            Simbolo s  = e.Obtener(id);

            if (s == null)
            {
                Console.WriteLine("No se encontro el simbolo " + id + " en este entorno");
                return;
            }

            //Si se tiene un simbolo valido
            Tipos  tipoaAsignar = asignacion.GetTipo(e);
            object valor        = asignacion.GetValor(e);

            if (!tipoaAsignar.Equals(s.tipo))
            {
                //Intento realizar un casteo
                Casteo cast      = new Casteo(s.tipo, tipoaAsignar, valor);
                Tipos  tipoNuevo = cast.GetTipo(e);
                if (!tipoNuevo.Equals(Tipos.NULL))
                {
                    object nuevoValor = cast.GetValor(e);
                    if (nuevoValor == null)
                    {
                        Console.WriteLine("Ocurrio un error al ejecutar el cast");
                        return;
                    }
                    //Si se obtuvo un valor valido del cast
                    s.valor = nuevoValor;
                }
                //Si no se puede realizar el casteo
                else
                {
                    Console.WriteLine("No se puede asigar un tipo difrente a " + s.tipo + " al identificador: " + id);
                }
                return;
            }

            //Si el tipo de asignacion y del simbolo son iguales
            if (valor == null)
            {
                Console.WriteLine("El valor calculado en la asignacion del id " + id + " es null");
                return;
            }

            //Si es un objeto
            if (s is Objeto objeto && valor is Entorno atributos)
            {
                objeto.atributos = atributos;
                return;
            }
            //Si es una List
            if (s is ListCollection list && valor is List <object> valores)
            {
                list.valores = valores;
                return;
            }

            //Si el valor calculado es valido
            s.valor = valor;
        }
Beispiel #10
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            Object valExpr = Expr.GetValor(e, log, errores);

            if (valExpr != null)
            {
                if (valExpr is Throw)
                {
                    return(valExpr);
                }

                if (Target is Identificador iden)
                {
                    Simbolo sim = Target.GetSimbolo(e);

                    if (sim != null)
                    {
                        if (sim.Tipo.Equals(Expr.Tipo))
                        {
                            sim.Valor = valExpr;
                            return(null);
                        }
                        else
                        {
                            if (sim.Tipo.IsCollection() && Expr.Tipo.IsCollection() && iden.IsId2)
                            {
                                if (sim.Tipo.EqualsCollection(Expr.Tipo))
                                {
                                    if (valExpr is Collection collection)
                                    {
                                        sim.Tipo.Clave = collection.Tipo.Clave;
                                        sim.Tipo.Valor = collection.Tipo.Valor;
                                        sim.Valor      = collection;
                                        return(null);
                                    }
                                }
                            }
                            else
                            {
                                Casteo cast = new Casteo(sim.Tipo, new Literal(Expr.Tipo, valExpr, 0, 0), 0, 0)
                                {
                                    Mostrar = false
                                };
                                valExpr = cast.GetValor(e, log, errores);

                                if (valExpr != null)
                                {
                                    if (valExpr is Throw)
                                    {
                                        return(valExpr);
                                    }

                                    sim.Valor = valExpr;
                                    return(null);
                                }
                            }
                        }

                        errores.AddLast(new Error("Semántico", "El valor no corresponde al tipo de la variable.", Linea, Columna));
                        return(null);
                    }
                    if (iden.IsId2)
                    {
                        errores.AddLast(new Error("Semántico", "No se ha declarado una variable con el id: " + Target.GetId() + ".", Linea, Columna));
                    }
                    else
                    {
                        return(new Throw("ColumnException", Linea, Columna));
                    }
                }
                else if (Target is AtributoRef atributo)
                {
                    atributo.GetObjeto = true;

                    object obj = atributo.GetValor(e, log, errores);

                    if (obj != null)
                    {
                        if (obj is Throw)
                        {
                            return(obj);
                        }

                        Simbolo sim = (Simbolo)obj;

                        if (sim.Tipo.Equals(Expr.Tipo))
                        {
                            sim.Valor = valExpr;
                            return(null);
                        }
                        else
                        {
                            Casteo cast = new Casteo(sim.Tipo, new Literal(Expr.Tipo, valExpr, 0, 0), 0, 0)
                            {
                                Mostrar = false
                            };
                            valExpr = cast.GetValor(e, log, errores);

                            if (valExpr != null)
                            {
                                if (valExpr is Throw)
                                {
                                    return(valExpr);
                                }

                                sim.Valor = valExpr;
                                return(null);
                            }
                        }

                        errores.AddLast(new Error("Semántico", "El valor no corresponde al tipo de la variable.", Linea, Columna));
                        return(null);
                    }
                    errores.AddLast(new Error("Semántico", "No se ha declarado una variable con el id: " + Target.GetId() + ".", Linea, Columna));
                }
                else if (Target is Acceso acceso)
                {
                    acceso.GetCollection = true;

                    object obj = acceso.GetValor(e, log, errores);

                    if (obj != null)
                    {
                        if (obj is Throw)
                        {
                            return(obj);
                        }

                        CollectionValue collection = (CollectionValue)obj;

                        if (acceso.Tipo.Equals(Expr.Tipo))
                        {
                            if (acceso.Collec != null)
                            {
                                if (acceso.Collec.Tipo.IsSet())
                                {
                                    if (acceso.Collec.Contains(valExpr))
                                    {
                                        errores.AddLast(new Error("Semántico", "Ya existe el valor: " + valExpr.ToString() + " en el Set.", Linea, Columna));
                                        return(null);
                                    }
                                }
                            }

                            collection.Valor = valExpr;
                            return(null);
                        }
                        else
                        {
                            Casteo cast = new Casteo(acceso.Tipo, new Literal(Expr.Tipo, valExpr, 0, 0), 0, 0)
                            {
                                Mostrar = false
                            };
                            valExpr = cast.GetValor(e, log, errores);

                            if (valExpr != null)
                            {
                                if (valExpr is Throw)
                                {
                                    return(valExpr);
                                }

                                if (acceso.Collec != null)
                                {
                                    if (acceso.Collec.Tipo.IsSet())
                                    {
                                        if (acceso.Collec.Contains(valExpr))
                                        {
                                            errores.AddLast(new Error("Semántico", "Ya existe el valor: " + valExpr.ToString() + " en el Set.", Linea, Columna));
                                            return(null);
                                        }
                                    }
                                }

                                collection.Valor = valExpr;
                                return(null);
                            }
                        }

                        errores.AddLast(new Error("Semántico", "El valor no corresponde al tipo de la variable.", Linea, Columna));
                        return(null);
                    }
                    errores.AddLast(new Error("Semántico", "No se ha declarado una variable con el id: " + Target.GetId() + ".", Linea, Columna));
                }
            }
            return(null);
        }
Beispiel #11
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            if (Tipo.IsObject())
            {
                BD actual = e.Master.Actual;

                if (actual != null)
                {
                    if (actual.GetUserType(Tipo.Objeto) == null)
                    {
                        errores.AddLast(new Error("Semántico", "No existe un User Type con el id: " + Tipo.Objeto + " en la base de datos.", Linea, Columna));
                        return(null);
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "No se ha seleccionado una base de datos, no se pudo buscar el User Type.", Linea, Columna));
                    return(null);
                }
            }

            foreach (Expresion target in Target)
            {
                object valorExpr = null;

                if (Target.Last.Value.Equals(target))
                {
                    if (Expr != null)
                    {
                        valorExpr = Expr.GetValor(e, log, errores);

                        if (valorExpr == null)
                        {
                            return(null);
                        }

                        if (valorExpr is Throw)
                        {
                            return(valorExpr);
                        }

                        if (!Tipo.Equals(Expr.Tipo))
                        {
                            Casteo cast = new Casteo(Tipo, new Literal(Expr.Tipo, valorExpr, 0, 0), 0, 0)
                            {
                                Mostrar = false
                            };

                            valorExpr = cast.GetValor(e, log, errores);

                            if (valorExpr == null)
                            {
                                if (valorExpr is Throw)
                                {
                                    return(valorExpr);
                                }

                                errores.AddLast(new Error("Semántico", "El valor no corresponde al tipo declarado.", Linea, Columna));
                                return(null);
                            }
                        }

                        if (valorExpr is Collection collection)
                        {
                            Tipo.Clave = collection.Tipo.Clave;
                            Tipo.Valor = collection.Tipo.Valor;
                        }
                    }
                }

                if (target is Identificador id)
                {
                    if (id.IsId2)
                    {
                        Simbolo sim = e.GetLocal(id.Id);

                        if (sim != null)
                        {
                            return(new Throw("ObjectAlreadyExists", Linea, Columna));
                            //errores.AddLast(new Error("Semántico", "Ya se ha declarado una variable con el id: " + id.Id + ".", Linea, Columna));
                            //continue;
                        }

                        sim = new Simbolo(Tipo, Rol.VARIABLE, id.Id.ToLower(), valorExpr);
                        e.Add(sim);
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "No se puede declarar una variable sin el @ al inicio.", Linea, Columna));
                        continue;
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "Solo se pueden declarar variables.", Linea, Columna));
                }
            }


            return(null);
        }