Ejemplo n.º 1
0
 public Acceso(Expresion target, Expresion expr, int linea, int columna) : base(linea, columna)
 {
     Target        = target;
     Expr          = expr;
     GetCollection = false;
 }
Ejemplo n.º 2
0
        public override object GetValor(Entorno e, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            Expresion clave = (Expresion)Collection.ElementAt(0).Clave;
            Expresion valor = (Expresion)Collection.ElementAt(0).Valor;

            object valClave = clave.GetValor(e, log, errores);
            object valValor = valor.GetValor(e, log, errores);

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

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

                Tipo = new Tipo(clave.Tipo, valor.Tipo);

                Collection map = new Collection(new Tipo(clave.Tipo, valor.Tipo));
                map.Insert(valClave, valValor);

                for (int i = 1; i < Collection.Count(); i++)
                {
                    CollectionValue value = Collection.ElementAt(i);
                    clave    = (Expresion)value.Clave;
                    valor    = (Expresion)value.Valor;
                    valClave = clave.GetValor(e, log, errores);
                    valValor = valor.GetValor(e, log, errores);

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

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

                        if (map.Tipo.Clave.Equals(clave.Tipo) && map.Tipo.Valor.Equals(valor.Tipo))
                        {
                            if (map.Get(valClave) == null)
                            {
                                map.Insert(valClave, valValor);
                            }
                            else
                            {
                                errores.AddLast(new Error("Semántico", "Ya existe un valor con la clave: " + valClave.ToString() + " en Map.", Linea, Columna));
                            }
                        }
                        else
                        {
                            Casteo cast1 = new Casteo(map.Tipo.Clave, new Literal(clave.Tipo, valClave, 0, 0), 0, 0)
                            {
                                Mostrar = false
                            };

                            Casteo cast2 = new Casteo(map.Tipo.Valor, new Literal(valor.Tipo, valValor, 0, 0), 0, 0)
                            {
                                Mostrar = false
                            };

                            valClave = cast1.GetValor(e, log, errores);
                            valValor = cast2.GetValor(e, log, errores);

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

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

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

                                continue;
                            }

                            errores.AddLast(new Error("Semántico", "Los tipos no coinciden con la clave:valor del Map.", Linea, Columna));
                        }
                        //continue;
                    }
                    //return null;
                }

                return(map);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public override object GetValor(Entorno e, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            BD actual = e.Master.Actual;

            if (actual != null)
            {
                Simbolo sim = actual.GetUserType(Id);
                if (sim != null)
                {
                    if (Atributos.Count() == ((Entorno)sim.Valor).Simbolos.Count())
                    {
                        LinkedList <Simbolo> sims = new LinkedList <Simbolo>();
                        for (int i = 0; i < Atributos.Count(); i++)
                        {
                            Simbolo   s       = ((Entorno)sim.Valor).Simbolos.ElementAt(i);
                            Expresion expr    = Atributos.ElementAt(i);
                            object    valExpr = expr.GetValor(e, log, errores);

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

                                if (s.Tipo.Equals(expr.Tipo))
                                {
                                    sims.AddLast(new Simbolo(s.Tipo, Rol.ATRIBUTO, s.Id, valExpr));
                                    continue;
                                }
                                else
                                {
                                    if (s.Tipo.IsCollection() && expr.Tipo.IsCollection())
                                    {
                                        if (s.Tipo.EqualsCollection(expr.Tipo))
                                        {/*verificar mas tipos*/
                                            sims.AddLast(new Simbolo(s.Tipo, Rol.ATRIBUTO, s.Id, valExpr));
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        Casteo cast = new Casteo(s.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);
                                            }

                                            sims.AddLast(new Simbolo(s.Tipo, Rol.ATRIBUTO, s.Id, valExpr));
                                            continue;
                                        }
                                    }
                                }
                            }

                            errores.AddLast(new Error("Semántico", "Los valores no coinciden con el User Type.", Linea, Columna));
                            return(null);
                        }
                        Tipo = new Tipo(Id.ToLower());
                        return(new Objeto(Id.ToLower(), new Entorno(null, sims)));
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "Los valores no coinciden con el User Type.", Linea, Columna));
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "No existe un User Type con el id: " + Id + " en la base de datos.", Linea, Columna));
                }
            }
            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);
        }
Ejemplo n.º 4
0
        public override object GetValor(Entorno e, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            Expresion valor    = Collection.ElementAt(0);
            object    valValor = valor.GetValor(e, log, errores);

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

                Tipo = new Tipo(Type.LIST, valor.Tipo);
                Collection list = new Collection(new Tipo(Type.LIST, valor.Tipo));
                list.Insert(list.Posicion++, valValor);

                for (int i = 1; i < Collection.Count(); i++)
                {
                    valor    = Collection.ElementAt(i);
                    valValor = valor.GetValor(e, log, errores);

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

                        if (list.Tipo.Valor.Equals(valor.Tipo))
                        {
                            list.Insert(list.Posicion++, valValor);
                        }
                        else
                        {
                            Casteo cast = new Casteo(list.Tipo.Valor, 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);
                                }

                                list.Insert(list.Posicion++, valValor);
                                continue;
                            }
                            errores.AddLast(new Error("Semántico", "El tipo no coinciden con el valor del List.", Linea, Columna));
                        }
                        //continue;
                    }
                    //return null;
                }

                return(list);
            }
            return(null);
        }
Ejemplo n.º 5
0
 public Where(Expresion expr, LinkedList <Expresion> inExpr, int linea, int columna) : base(linea, columna)
 {
     Expr   = expr;
     InExpr = inExpr;
 }
Ejemplo n.º 6
0
 public Where(Expresion expr, int linea, int columna) : base(linea, columna)
 {
     Expr = expr;
 }
Ejemplo n.º 7
0
 public Ternario(Expresion expr, Expresion v, Expresion f, int linea, int columna) : base(linea, columna)
 {
     Expr = expr;
     V    = v;
     F    = f;
 }
Ejemplo n.º 8
0
 public Casteo(Tipo tipo, Expresion expr, int linea, int columna) : base(linea, columna)
 {
     Tipo    = tipo;
     Expr    = expr;
     Mostrar = true;
 }
Ejemplo n.º 9
0
        public override object GetValor(Entorno e, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            Expresion valor    = Collection.ElementAt(0);
            object    valValor = valor.GetValor(e, log, errores);

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

                Tipo = new Tipo(Type.SET, valor.Tipo);

                Collection set = new Collection(new Tipo(Type.SET, valor.Tipo));
                set.Insert(set.Posicion++, valValor);

                for (int i = 1; i < Collection.Count(); i++)
                {
                    valor    = Collection.ElementAt(i);
                    valValor = valor.GetValor(e, log, errores);

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

                        if (set.Tipo.Valor.Equals(valor.Tipo))
                        {
                            if (!set.Contains(valValor))
                            {
                                set.Insert(set.Posicion++, valValor);
                            }
                            else
                            {
                                errores.AddLast(new Error("Semántico", "Ya existe el valor: " + valValor.ToString() + " en el Set.", Linea, Columna));
                            }
                        }
                        else
                        {
                            Casteo cast = new Casteo(set.Tipo.Valor, 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);
                                }

                                if (!set.Contains(valValor))
                                {
                                    set.Insert(set.Posicion++, valValor);
                                }
                                else
                                {
                                    errores.AddLast(new Error("Semántico", "Ya existe el valor: " + valValor.ToString() + " en el Set.", Linea, Columna));
                                }

                                continue;
                            }

                            errores.AddLast(new Error("Semántico", "El tipo no coinciden con el valor del Set.", Linea, Columna));
                        }
                        //continue;
                    }
                    //return null;
                }

                set.Ordenar();

                return(set);
            }
            return(null);
        }