Exemplo n.º 1
0
        /*
         * Metodo que se encargara de ver el tipo de objeto a guardar
         * @param {valor} valor que se almacenara
         * @return {string} cadena de salida
         */

        private string getValor(object valor, string nombre, string tabulacion)
        {
            string salida = "";

            if (!nombre.Equals("none"))
            {
                salida = tabulacion + "\"" + nombre + "\" =";
            }
            if (valor.GetType() == typeof(string))
            {
                salida += "\"" + valor + "\"";
            }
            else if (valor.GetType() == typeof(int) || valor.GetType() == typeof(double) || valor.GetType() == typeof(Boolean))
            {
                salida += valor;
            }
            else if (valor.GetType() == typeof(DateTime))
            {
                string fecha = ((DateTime)valor).ToString("yyyy-MM-dd");
                salida += "'" + fecha + "'";
            }
            else if (valor.GetType() == typeof(TimeSpan))
            {
                string hora = ((TimeSpan)valor).ToString(@"hh\:mm\:ss");
                salida += "'" + hora + "'";
            }
            else if (valor.GetType() == typeof(InstanciaUserType))
            {
                InstanciaUserType temp = (InstanciaUserType)valor;
                salida += "< \n";
                if (temp.lista != null)
                {
                    var nodeLast = (temp.lista.Count() > 0) ? temp.lista.Last() : null;
                    foreach (Atributo a in temp.lista)
                    {
                        salida += getValor(a.valor, a.nombre, tabulacion + "\t");
                        if (!a.Equals(nodeLast))
                        {
                            salida += ",\n";
                        }
                        else
                        {
                            salida += "\n";
                        }
                    }
                }
                salida += tabulacion + ">";
            }
            else if (valor.GetType() == typeof(Map))
            {
                Map temp = (Map)valor;
                salida += "< \n";
                if (temp.datos != null)
                {
                    var nodeLast = (temp.datos.Count() > 0) ? temp.datos.Last() : null;
                    foreach (KeyValue a in temp.datos)
                    {
                        salida += getValor(a.value, a.key.ToString(), tabulacion + "\t");
                        if (!a.Equals(nodeLast))
                        {
                            salida += ",\n";
                        }
                        else
                        {
                            salida += "\n";
                        }
                    }
                }
                salida += tabulacion + ">";
            }
            else if (valor.GetType() == typeof(List))
            {
                List temp = (List)valor;
                salida += "[";
                if (temp.lista != null)
                {
                    var nodelast = (temp.lista.Count() > 0) ? temp.lista.Last() : null;
                    foreach (object o in temp.lista)
                    {
                        salida += getValor(o, "none", "no");
                        if (!o.Equals(nodelast))
                        {
                            salida += ",";
                        }
                    }
                    salida += "]";
                }
            }
            else if (valor.GetType() == typeof(Set))
            {
                Set temp = (Set)valor;
                salida += "[";
                if (temp.datos != null)
                {
                    var nodelast = (temp.datos.Count() > 0) ? temp.datos.Last() : null;
                    foreach (object o in temp.datos)
                    {
                        salida += getValor(o, "none", "no");
                        if (!o.Equals(nodelast))
                        {
                            salida += ",";
                        }
                    }
                    salida += "]";
                }
            }
            return(salida);
        }
Exemplo n.º 2
0
        /*
         * Metodo que inserta Especialmente en la tabla
         * @t Tabla donde guardaremos los datos
         * @mensajes output
         * @TablaDeSimbolos Tabla de simoblos padre
         * @user usuario que esta ejecutando las acciones
         * @db base de datos actual
         * @baseD nombre de la base de datos por referencia
         */
        private object guardadoEspecial(Tabla t, TablaDeSimbolos ts, BaseDeDatos db, Ambito ambito, TablaDeSimbolos tsT)
        {
            Mensaje             mensa    = new Mensaje();
            string              user     = ambito.usuario;
            string              baseD    = ambito.baseD;
            LinkedList <string> mensajes = ambito.mensajes;

            if (values.Count() == campos.Count())
            {
                if (existColumn(t.columnas, campos, mensajes, ambito))
                {
                    LinkedList <Atributo> info = new LinkedList <Atributo>();
                    LinkedList <int>      pos  = new LinkedList <int>();
                    int posicion = 0;
                    foreach (Columna columna in t.columnas)
                    {
                        Boolean flag = false;
                        int     i    = 0;

                        foreach (string campo in campos)
                        {
                            if (campo.Equals(columna.name))
                            {
                                if (columna.tipo.Equals("counter"))
                                {
                                    ambito.listadoExcepciones.AddLast(new Excepcion("countertypeexception", "No se le puede insertar un valor a un tipo Counter"));
                                    mensajes.AddLast(mensa.error("No se le puede insertar un valor a un tipo Counter", l, c, "Semantico"));
                                    return(null);
                                }
                                else
                                {
                                    flag = true;
                                    object   op1 = (values.ElementAt(i) == null) ? null : values.ElementAt(i).ejecutar(ts, ambito, tsT);
                                    Atributo a   = checkinfo(columna, op1, values.ElementAt(i), mensajes, db, ambito);
                                    if (a != null)
                                    {
                                        info.AddLast(a);
                                    }
                                    else
                                    {
                                        return(null);
                                    }
                                }
                            }
                            i++;
                        }
                        if (!flag)
                        {
                            if (columna.pk)
                            {
                                if (columna.tipo.Equals("counter"))
                                {
                                    int index = getLastCounter(posicion, t.datos);
                                    info.AddLast(new Atributo(columna.name, index + 1, "counter"));
                                }
                                else
                                {
                                    Atributo a = checkinfo(columna, null, null, mensajes, db, ambito);
                                    if (a != null)
                                    {
                                        info.AddLast(a);
                                    }
                                    else
                                    {
                                        return(null);
                                    }
                                    pos.AddLast(posicion);
                                }
                            }
                            else
                            {
                                object val;
                                if (columna.tipo.Equals("string") || columna.tipo.Equals("date") || columna.tipo.Equals("time"))
                                {
                                    val = null;
                                }
                                else if (columna.tipo.Equals("double") || columna.tipo.Equals("int"))
                                {
                                    val = 0;
                                }
                                else if (columna.tipo.Equals("boolean"))
                                {
                                    val = false;
                                }
                                else if (columna.tipo.Equals("counter"))
                                {
                                    val = getLastCounter(posicion, t.datos) + 1;
                                }
                                else if (columna.tipo.Contains("map") || columna.tipo.Contains("list") || columna.tipo.Contains("set"))
                                {
                                    mensajes.AddLast(mensa.error("El tipo: " + columna.tipo + " no puede ser null", l, c, "Semantico"));
                                    return(null);
                                }
                                else
                                {
                                    val = new InstanciaUserType(columna.tipo, null);
                                }

                                Atributo a = checkinfo(columna, val, 0, mensajes, db, ambito);
                                if (a != null)
                                {
                                    info.AddLast(a);
                                }
                                else
                                {
                                    return(null);
                                }
                            }
                        }
                        else if (columna.pk)
                        {
                            pos.AddLast(posicion);
                        }
                        posicion++;
                    }

                    if (!checkPrimaryKey(pos, info, mensajes, t.datos, 0))
                    {
                        t.datos.AddLast(new Data(info));
                        mensajes.AddLast(mensa.message("Se inserto exitosamente la informacion"));
                        return("");
                    }
                    else
                    {
                        mensajes.AddLast(mensa.error("Ya hay un dato que posee esa clave primaria", l, c, "Semantico"));
                    }
                }
            }
            else
            {
                ambito.listadoExcepciones.AddLast(new Excepcion("valuesexception", "No coinciden la cantidad de campos con la cantidad de valores"));
                mensajes.AddLast(mensa.error("No coinciden la cantidad de campos con la cantidad de valores", l, c, "Semantico"));
            }


            return(null);
        }
Exemplo n.º 3
0
        /*
         * Metodo que verificara el tipo a guardar
         * @columna columan actual
         * @valor es el valor  a guardar
         * @original es la expresion sin ejecutar
         * @mensajes output de salida
         * @db BaseDeDatos actual
         */

        private Atributo checkinfo(Columna columna, object valor, object original, LinkedList <string> mensajes, BaseDeDatos db, Ambito ambito)
        {
            Mensaje mensa = new Mensaje();

            if (original == null)
            {
                if (!columna.pk)
                {
                    if (columna.tipo.Equals("string") || columna.tipo.Equals("date") || columna.tipo.Equals("time"))
                    {
                        return(new Atributo(columna.name, null, columna.tipo));
                    }
                    else if (columna.tipo.Equals("int") || columna.tipo.Equals("double") || columna.tipo.Equals("boolean") || columna.tipo.Contains("map") || columna.tipo.Contains("list") || columna.tipo.Contains("set"))
                    {
                        ambito.listadoExcepciones.AddLast(new Excepcion("valuesexception", "No se le puede asignar a un tipo: " + columna.tipo + " un valor null"));
                        mensajes.AddLast(mensa.error("No se le puede asignar a un tipo: " + columna.tipo + " un valor null", l, c, "Semantico"));
                    }
                    else
                    {
                        Boolean temp = TablaBaseDeDatos.getUserType(columna.tipo, db);
                        if (temp)
                        {
                            return(new Atributo(columna.name, new InstanciaUserType(columna.tipo, null), columna.tipo));
                        }
                        else
                        {
                            mensajes.AddLast(mensa.error("No existe el USER TYPE: " + columna.tipo + " en la DB: " + db.nombre, l, c, "Semantico"));
                        }
                    }
                }
                else
                {
                    ambito.listadoExcepciones.AddLast(new Excepcion("valuesexception", "La columna: " + columna.name + " es clave primaria no puede asignarsele un valor null"));

                    mensajes.AddLast(mensa.error("La columna: " + columna.name + " es clave primaria no puede asignarsele un valor null", l, c, "Semantico"));
                }
            }
            else
            {
                if (valor != null)
                {
                    if (columna.tipo.Equals("string") && valor.GetType() == typeof(string))
                    {
                        return(new Atributo(columna.name, (string)valor, "string"));
                    }
                    else if (columna.tipo.Equals("int") && valor.GetType() == typeof(int))
                    {
                        return(new Atributo(columna.name, (int)valor, "int"));
                    }
                    else if (columna.tipo.Equals("double") && valor.GetType() == typeof(Double))
                    {
                        return(new Atributo(columna.name, (Double)valor, "double"));
                    }
                    else if (columna.tipo.Equals("boolean") && valor.GetType() == typeof(Boolean))
                    {
                        return(new Atributo(columna.name, (Boolean)valor, "boolean"));
                    }
                    else if (columna.tipo.Equals("date") && valor.GetType() == typeof(DateTime))
                    {
                        return(new Atributo(columna.name, (DateTime)valor, "date"));
                    }
                    else if (columna.tipo.Equals("time") && valor.GetType() == typeof(TimeSpan))
                    {
                        return(new Atributo(columna.name, (TimeSpan)valor, "time"));
                    }
                    else if (columna.tipo.Equals("counter") && valor.GetType() == typeof(int))
                    {
                        return(new Atributo(columna.name, (int)valor, "int"));
                    }
                    else if (columna.tipo.Contains("map") && valor.GetType() == typeof(Map))
                    {
                        Map    temp = (Map)valor;
                        string tipo = columna.tipo.TrimStart('m').TrimStart('a').TrimStart('p').TrimStart('<');
                        if (tipo.EndsWith('>'))
                        {
                            tipo = tipo.Substring(0, tipo.Length - 1);
                        }
                        if (temp.id.Equals(tipo))
                        {
                            return(new Atributo(columna.name, temp, tipo));
                        }
                        mensajes.AddLast(mensa.error("No coinciden los tipos de map: " + tipo + " con: " + temp.id, l, c, "Semantico"));
                    }
                    else if (columna.tipo.Contains("set") && valor.GetType() == typeof(Set))
                    {
                        Set temp = (Set)valor;

                        string tipo = columna.tipo.TrimStart('s').TrimStart('e').TrimStart('t').TrimStart('<');
                        if (tipo.EndsWith('>'))
                        {
                            tipo = tipo.Substring(0, tipo.Length - 1);
                        }
                        if (temp.id.Equals(tipo))
                        {
                            return(new Atributo(columna.name, temp, tipo));
                        }
                        mensajes.AddLast(mensa.error("No coinciden los tipos de Set: " + tipo + " con: " + temp.id, l, c, "Semantico"));
                    }
                    else if (columna.tipo.Contains("list") && valor.GetType() == typeof(List))
                    {
                        List temp = (List)valor;

                        string tipo = columna.tipo.TrimStart('l').TrimStart('i').TrimStart('s').TrimStart('t').TrimStart('<');
                        if (tipo.EndsWith('>'))
                        {
                            tipo = tipo.Substring(0, tipo.Length - 1);
                        }
                        if (temp.id.Equals(tipo))
                        {
                            return(new Atributo(columna.name, temp, tipo));
                        }
                        mensajes.AddLast(mensa.error("No coinciden los tipos de List: " + tipo + " con: " + temp.id, l, c, "Semantico"));
                    }
                    else if (valor.GetType() == typeof(InstanciaUserType))
                    {
                        InstanciaUserType temp = (InstanciaUserType)valor;
                        if (columna.tipo.Equals(temp.tipo))
                        {
                            return(new Atributo(columna.name, (InstanciaUserType)valor, columna.tipo));
                        }
                        else
                        {
                            mensajes.AddLast(mensa.error("No se le puede asignar a la columna: " + columna.name + " un tipo: " + temp.tipo, l, c, "Semantico"));
                        }
                    }
                    else
                    {
                        ambito.listadoExcepciones.AddLast(new Excepcion("valuesexception", "No se puede asignar a la columna: " + columna.name + " el valor: " + valor));
                        mensajes.AddLast(mensa.error("No se puede asignar a la columna: " + columna.name + " el valor: " + valor, l, c, "Semantico"));
                    }
                }
                else
                {
                    if (columna.tipo.Equals("string") || columna.tipo.Equals("date") || columna.tipo.Equals("time"))
                    {
                        return(new Atributo(columna.name, null, columna.tipo));
                    }
                    else if (columna.tipo.Equals("boolean") || columna.tipo.Equals("int") || columna.tipo.Equals("double") || columna.tipo.Contains("map") || columna.tipo.Contains("list") || columna.tipo.Contains("set"))
                    {
                        ambito.listadoExcepciones.AddLast(new Excepcion("valuesexception", "No se puede asignar a la columna: " + columna.name + " el valor: " + valor + valor));

                        mensajes.AddLast(mensa.error("No se puede asignar a la columna: " + columna.name + " el valor: " + valor, l, c, "Semantico"));
                    }
                    else
                    {
                        return(new Atributo(columna.name, new InstanciaUserType(columna.tipo, null), columna.tipo));
                    }
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        public string consulta(TablaSelect tabla)
        {
            string resultado = "[+DATA]\n";

            resultado += "\n\t<table class=\"table\">\n";
            resultado += "\n\t<thead class=\"thead-dark\">\n";
            resultado += "\t<tr>\n";
            foreach (Columna columa in tabla.columnas)
            {
                resultado += "\t\t<th scope = \"col\">" + columa.name + "</th>\n";
            }
            resultado += "\t</tr>\n";
            resultado += "\t</thead>\n";
            resultado += "\t<tbody>\n";
            foreach (Data data in tabla.datos)
            {
                resultado += "\t<tr>\n";
                foreach (Atributo atributo in data.valores)
                {
                    if (atributo.valor != null)
                    {
                        if (atributo.valor.GetType() == typeof(Map))
                        {
                            string temp = "[";
                            foreach (KeyValue key in ((Map)atributo.valor).datos)
                            {
                                if (key.value != null)
                                {
                                    if (key.value.GetType() == typeof(InstanciaUserType))
                                    {
                                        InstanciaUserType tempInstancia = (InstanciaUserType)key.value;
                                        temp += key.key + ": [" + getStringUser(tempInstancia.lista) + "] ,";
                                    }
                                    else
                                    {
                                        temp += key.key + ":" + key.value + ",";
                                    }
                                }
                                else
                                {
                                    temp += key.key + ":" + key.value + ",";
                                }
                            }
                            temp       = temp.TrimStart(',');
                            temp      += "]";
                            resultado += "\t\t<td>" + temp + "</td>\n";
                        }
                        else if (atributo.valor.GetType() == typeof(Set))
                        {
                            string temp = "[";
                            foreach (object p in ((Set)atributo.valor).datos)
                            {
                                if (p != null)
                                {
                                    if (p.GetType() == typeof(InstanciaUserType))
                                    {
                                        InstanciaUserType tempInstancia = (InstanciaUserType)p;
                                        temp += " [" + getStringUser(tempInstancia.lista) + "] ,";
                                    }
                                    else
                                    {
                                        temp += p + ",";
                                    }
                                }
                                else
                                {
                                    temp += p + ",";
                                }
                            }
                            temp       = temp.TrimStart(',');
                            temp      += "]";
                            resultado += "\t\t<td>" + temp + "</td>\n";
                        }
                        else if (atributo.valor.GetType() == typeof(List))
                        {
                            string temp = "[";
                            foreach (object p in ((List)atributo.valor).lista)
                            {
                                if (p != null)
                                {
                                    if (p.GetType() == typeof(InstanciaUserType))
                                    {
                                        InstanciaUserType tempInstancia = (InstanciaUserType)p;
                                        temp += " [" + getStringUser(tempInstancia.lista) + "] ,";
                                    }
                                    else
                                    {
                                        temp += p + ",";
                                    }
                                }
                                else
                                {
                                    temp += p + ",";
                                }
                            }
                            temp       = temp.TrimStart(',');
                            temp      += "]";
                            resultado += "\t\t<td>" + temp + "</td>\n";
                        }
                        else if (atributo.valor.GetType() == typeof(InstanciaUserType))
                        {
                            string temp = "[";
                            foreach (Atributo a in ((InstanciaUserType)atributo.valor).lista)
                            {
                                temp += a.nombre + ":" + a.valor + ",";
                            }
                            temp       = temp.TrimStart(',');
                            temp      += "]";
                            resultado += "\t\t<td>" + temp + "</td>\n";
                        }
                        else
                        {
                            resultado += "\t\t<td>" + atributo.valor.ToString() + "</td>";
                        }
                    }
                }
                resultado += "\t</tr>\n";
            }
            resultado += "\t</tbody>\n";
            resultado += "\t</table>\n";
            resultado += "[-DATA]";
            return(resultado);
        }
Exemplo n.º 5
0
        /*
         * Metodo de la implementacion
         * @ts tabla de simbolos global
         * @user usuario que ejecuta la accion
         * @baseD base de datos donde estamos ejecutando todo
         * @mensajes linkedlist con la salida deseada
         */
        public object ejecutar(TablaDeSimbolos ts, Ambito ambito, TablaDeSimbolos tsT)
        {
            Mensaje         ms        = new Mensaje();
            TablaDeSimbolos newAmbito = new TablaDeSimbolos();

            foreach (Simbolo s in ambito.tablaPadre)
            {
                newAmbito.AddLast(s);
            }

            if (parametros.Count() == valores.Count())
            {
                //-------------------------------------- CREACION Y ASIGNACION DE PARAMETROS -----------------------------------------------------
                for (int i = 0; i < parametros.Count(); i++)
                {
                    Declaracion d = (Declaracion)parametros.ElementAt(i);
                    d.parametro = true;
                    object rd = d.ejecutar(newAmbito, ambito, tsT);
                    if (rd == null)
                    {
                        return(null);
                    }
                    Asignacion a = new Asignacion(d.id, l, c, valores.ElementAt(i), "ASIGNACION");
                    a.tPadre = ts;
                    object ra = a.ejecutar(newAmbito, ambito, tsT);
                    if (ra == null)
                    {
                        return(null);
                    }
                }
                //---------------------------------------- INSTRUCCIONES DE LA FUNCION -----------------------------------------------------------
                foreach (InstruccionCQL ins in cuerpo)
                {
                    object r = ins.ejecutar(newAmbito, ambito, tsT);
                    if (r == null)
                    {
                        ambito.mensajes.AddLast(ms.error("Problema en la Funcion: " + id, l, c, "Semantico"));
                        return(null);
                    }
                    else if (r.GetType() == typeof(Retorno))
                    {
                        object re = ((Retorno)r).valor;
                        if (re != null)
                        {
                            if (re.GetType() == typeof(int) && tipo.Equals("int"))
                            {
                                return((int)re);
                            }
                            else if (re.GetType() == typeof(string) && tipo.Equals("string"))
                            {
                                return((String)re);
                            }
                            else if (re.GetType() == typeof(Boolean) && tipo.Equals("boolean"))
                            {
                                return((Boolean)re);
                            }
                            else if (re.GetType() == typeof(double) && tipo.Equals("double"))
                            {
                                return((Double)re);
                            }
                            else if (re.GetType() == typeof(DateTime) && tipo.Equals("date"))
                            {
                                return((DateTime)re);
                            }
                            else if (re.GetType() == typeof(TimeSpan) && tipo.Equals("time"))
                            {
                                return((TimeSpan)re);
                            }
                            else if (re.GetType() == typeof(Map) && tipo.Equals("map"))
                            {
                                return((Map)re);
                            }
                            else if (re.GetType() == typeof(List) && tipo.Equals("list"))
                            {
                                return((List)re);
                            }
                            else if (re.GetType() == typeof(Set) && tipo.Equals("set"))
                            {
                                return((Set)re);
                            }
                            else if (re.GetType() == typeof(TypeCursor) && tipo.Equals("cursor"))
                            {
                                return((TypeCursor)re);
                            }
                            else if (re.GetType() == typeof(InstanciaUserType))
                            {
                                InstanciaUserType temp = (InstanciaUserType)re;
                                if (temp.tipo.Equals(tipo))
                                {
                                    return(temp);
                                }
                                else
                                {
                                    ambito.mensajes.AddLast(ms.error("No coincide el tipo de USERTYPE", l, c, "Semantico"));
                                }
                            }
                            else
                            {
                                ambito.mensajes.AddLast(ms.error("No coincide el tipo: " + tipo + " con el valor: " + re, l, c, "Semantico"));
                            }
                            return(null);
                        }
                    }
                }
                ambito.mensajes.AddLast(ms.error("La funcion no posee ningun return", l, c, "Semantico"));
                return(null);
            }
            else
            {
                ambito.mensajes.AddLast(ms.error("No coinciden el numero de parametros con el numero de valores", l, c, "Semantico"));
            }

            return(null);
        }
        /*
         * METODO QUE VERIFICA LOS VALORES A GUARDAR
         * @param {op1} valor a guardar
         * @param {tipo} tipo de variable
         * @param {a} expresion original
         * @param {mensajes} output
         * @param {ts} tabla de variables
         */
        private object checkValues(object op1, string tipo, LinkedList <string> mensajes, TablaDeSimbolos ts, string id)
        {
            Mensaje mensa = new Mensaje();


            if (op1 != null)
            {
                if (op1.GetType() == typeof(string) && tipo.Equals("string"))
                {
                    ts.setValor(id, (string)op1);
                }
                else if (op1.GetType() == typeof(int) && tipo.Equals("int"))
                {
                    ts.setValor(id, (int)op1);
                }
                else if (op1.GetType() == typeof(int) && tipo.Equals("double"))
                {
                    ts.setValor(id, Convert.ToInt32((Double)op1));
                }
                else if (op1.GetType() == typeof(Double) && tipo.Equals("double"))
                {
                    ts.setValor(id, (Double)op1);
                }
                else if (op1.GetType() == typeof(Double) && tipo.Equals("int"))
                {
                    ts.setValor(id, Convert.ToDouble((int)op1));
                }
                else if (op1.GetType() == typeof(Boolean) && tipo.Equals("boolean"))
                {
                    ts.setValor(id, (Boolean)op1);
                }
                else if (op1.GetType() == typeof(DateTime) && tipo.Equals("date"))
                {
                    ts.setValor(id, (DateTime)op1);
                }
                else if (op1.GetType() == typeof(TimeSpan) && tipo.Equals("time"))
                {
                    ts.setValor(id, (TimeSpan)op1);
                }
                else if (op1.GetType() == typeof(Map) && tipo.Equals("map"))
                {
                    Map temp  = (Map)op1;
                    Map valor = (Map)ts.getValor(id);
                    if (valor.id.Equals(temp.id) || valor.id.Equals("none"))
                    {
                        ts.setValor(id, temp);
                        return("");
                    }
                    else
                    {
                        mensajes.AddLast(mensa.error("No coincide los tipos: " + valor.id + " con: " + temp.id, l, c, "Semantico"));
                        return(null);
                    }
                }
                else if (op1.GetType() == typeof(List) && tipo.Equals("list"))
                {
                    List temp = (List)op1;

                    List valor = (List)ts.getValor(id);
                    if (valor.id.Equals(temp.id) || valor.id.Equals("none"))
                    {
                        ts.setValor(id, temp);
                        return("");
                    }
                    else
                    {
                        mensajes.AddLast(mensa.error("No coincide los tipos: " + valor.id + " con: " + temp.id, l, c, "Semantico"));
                        return(null);
                    }
                }
                else if (tipo.Equals("set") && op1.GetType() == typeof(Set))
                {
                    Set original = (Set)ts.getValor(id);
                    Set temp     = (Set)op1;
                    if (original.id.Equals(temp.id) || original.id.Equals("none"))
                    {
                        object resp = temp.buscarRepetidos(mensajes, l, c);
                        if (resp == null)
                        {
                            return(null);
                        }
                        temp.order();
                        ts.setValor(id, temp);
                    }
                    else
                    {
                        mensajes.AddLast(mensa.error("No coincide los tipos: " + original.id + " con: " + temp.id, l, c, "Semantico"));
                        return(null);
                    }
                }
                else if (op1.GetType() == typeof(InstanciaUserType))
                {
                    InstanciaUserType temp = (InstanciaUserType)op1;
                    if (tipo.Equals(temp.tipo.ToLower()) || temp.tipo.Equals("none"))
                    {
                        ts.setValor(id, temp);
                        return("");
                    }
                    else
                    {
                        mensajes.AddLast(mensa.error("No se le puede asignar a la variable: " + id + " el valor: " + op1, l, c, "Semantico"));
                        return(null);
                    }
                }
                else
                {
                    mensajes.AddLast(mensa.error("No se le puede asignar a la variable: " + id + " el valor: " + op1, l, c, "Semantico"));
                    return(null);
                }
                return("");
            }
            else
            {
                if (tipo.Equals("string") || tipo.Equals("date") || tipo.Equals("time"))
                {
                    ts.setValor(id, null);
                }
                else if (tipo.Equals("int") || tipo.Equals("double") || tipo.Equals("boolean") || tipo.Equals("map") || tipo.Equals("list") || tipo.Equals("set"))
                {
                    mensajes.AddLast(mensa.error("No se le puede asignar a la variable: " + id + " el valor: null", l, c, "Semantico"));
                    return(null);
                }
                else
                {
                    ts.setValor(id, new InstanciaUserType(tipo, null));
                }
                return("");
            }
        }
Exemplo n.º 7
0
        /*
         * Metodo que se encargara de editar todos los campos
         * @ts tabla de simbolos padre
         * @user usuario que esta ejecutando las acciones
         * @baseD string por referencia de que base de datos estamos trabajando
         * @mensajes el output de la ejecucion
         * @tsT se encargara de guardar todos los datos en una tabla temporal para la tabla
         * @t tabla actual
         */

        private object changeAll(TablaDeSimbolos ts, Ambito ambito, Tabla t)
        {
            Mensaje             mensa    = new Mensaje();
            string              baseD    = ambito.baseD;
            LinkedList <string> mensajes = ambito.mensajes;
            BaseDeDatos         db       = TablaBaseDeDatos.getBase(baseD);

            foreach (Data data in t.datos)
            {
                TablaDeSimbolos tsT = new TablaDeSimbolos();
                guardarTemp(data.valores, tsT);
                if (checkColumns(t.columnas, mensajes, ambito))
                {
                    foreach (SetCQL set in asignacion)
                    {
                        foreach (Atributo atributo in data.valores)
                        {
                            object op1 = (set.valor == null) ? null : set.valor.ejecutar(ts, ambito, tsT);
                            if (set.operacion.Equals("NORMAL"))
                            {
                                if (set.campo.Equals(atributo.nombre))
                                {
                                    Atributo temp = checkinfo(getColumna(t.columnas, set.campo), op1, set.valor, mensajes, db, ambito);
                                    if (temp != null)
                                    {
                                        atributo.valor = temp.valor;
                                    }
                                    else
                                    {
                                        return(null);
                                    }
                                }
                            }
                            else
                            {
                                object op2 = (set.accesoUS == null) ? null : set.accesoUS.ejecutar(ts, ambito, tsT);

                                if (op2 != null)
                                {
                                    if (op2.GetType() == typeof(InstanciaUserType))
                                    {
                                        InstanciaUserType temp = (InstanciaUserType)op2;
                                        foreach (Atributo a in temp.lista)
                                        {
                                            if (a.nombre.Equals(set.campo))
                                            {
                                                Columna  co    = new Columna(a.nombre, a.tipo, false);
                                                Atributo temp2 = checkinfo(co, op1, set.valor, mensajes, db, ambito);
                                                if (temp2 != null)
                                                {
                                                    a.valor = temp2.valor;
                                                }
                                                else
                                                {
                                                    return(null);
                                                }
                                            }
                                        }
                                    }
                                    else if (op2.GetType() == typeof(Map))
                                    {
                                        object campo = (set.key == null) ? null : set.key.ejecutar(ts, ambito, tsT);
                                        Map    temp  = (Map)op2;
                                        string tipo  = temp.id.Split(new[] { ',' }, 2)[1];
                                        foreach (KeyValue ky in temp.datos)
                                        {
                                            if (ky.key.ToString().Equals(campo))
                                            {
                                                Columna  co    = new Columna(ky.key.ToString(), tipo, false);
                                                Atributo temp2 = checkinfo(co, op1, set.valor, mensajes, db, ambito);
                                                if (temp2 != null)
                                                {
                                                    ky.value = temp2.valor;
                                                }
                                                else
                                                {
                                                    return(null);
                                                }
                                            }
                                        }
                                        ambito.listadoExcepciones.AddLast(new Excepcion("indexoutexception", "No se encontro la key"));
                                    }
                                    else if (op2.GetType() == typeof(List))
                                    {
                                        List   temp  = (List)op2;
                                        object campo = (set.key == null) ? null : set.key.ejecutar(ts, ambito, tsT);
                                        if (campo != null)
                                        {
                                            if (campo.GetType() == typeof(int))
                                            {
                                                if ((int)campo > -1)
                                                {
                                                    if ((int)campo < temp.lista.Count())
                                                    {
                                                        if (temp.lista.Count() > 0)
                                                        {
                                                            var node  = temp.lista.First;
                                                            int index = 0;
                                                            while (node != null)
                                                            {
                                                                var nodeNext = node.Next;
                                                                if (index == (int)campo)
                                                                {
                                                                    Columna  co    = new Columna("", temp.id, false);
                                                                    Atributo temp2 = checkinfo(co, op1, set.valor, mensajes, db, ambito);
                                                                    if (temp2 != null)
                                                                    {
                                                                        node.Value = temp2.valor;
                                                                    }
                                                                    else
                                                                    {
                                                                        return(null);
                                                                    }
                                                                    break;
                                                                }
                                                                node = nodeNext;
                                                                index++;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ambito.listadoExcepciones.AddLast(new Excepcion("indexoutexception", "El index es mayor al tamaño de la lista"));
                                                        mensajes.AddLast(mensa.error("El index supera el tamanio de la lista", l, c, "Semantico"));
                                                        return(null);
                                                    }
                                                }
                                                else
                                                {
                                                    ambito.mensajes.AddLast(mensa.error("Index tiene que ser mayor a 0  ", l, c, "Semantico"));
                                                    mensajes.AddLast(mensa.error("El index debe de ser positivo: " + campo, l, c, "Semantico"));
                                                    return(null);
                                                }
                                            }
                                            else
                                            {
                                                mensajes.AddLast(mensa.error("El index debe de ser de tipo numerico: " + campo, l, c, "Semantico"));
                                                return(null);
                                            }
                                        }
                                        else
                                        {
                                            mensajes.AddLast(mensa.error("El index no puede ser null", l, c, "Semantico"));
                                            return(null);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }
            mensajes.AddLast(mensa.message("Datos actualizados con exito"));
            return("");
        }
        /*
         * Metodo que se implementa de la clase padre
         * @ts tabla de simbolos
         * @user usuario que ejecuta la accion
         * @baseD base de datos en la que se esta trabajando
         * @mensajes respuesta de errores o mensajes de salida
         */

        public object ejecutar(TablaDeSimbolos ts, Ambito ambito, TablaDeSimbolos tsT)
        {
            Mensaje             mensa = new Mensaje();
            TablaDeSimbolos     tablaT;
            LinkedList <string> mensajes = ambito.mensajes;

            if (tPadre != null)
            {
                tablaT = tPadre;
            }
            else
            {
                tablaT = ts;
            }


            object op1  = (a == null) ? null : a.ejecutar(tablaT, ambito, tsT);
            object atri = (atributo == null) ? null : atributo.ejecutar(tablaT, ambito, tsT);

            //--------------------------------------------- REALIZA UNA ASIGNACION NORMAL---------------------------------------------------------------
            if (operacion.Equals("ASIGNACION"))
            {
                string tipo = ts.getTipo(id);
                tipo = tipo.ToLower().TrimEnd().TrimStart();
                if (!tipo.Equals("none"))
                {
                    return(checkValues(op1, tipo, a, mensajes, ts));
                }
                else
                {
                    mensajes.AddLast(mensa.error("La variable: " + id + " no existe en este ambito", l, c, "Semantico"));
                }
            }
            //----------------------------------------------- REALIZA LA ASIGNACION DE UN ATRIBUTO ------------------------------------------------------
            else if (operacion.Equals("ASIGNACIONA"))
            {
                if (atri != null)
                {
                    if (atri.GetType() == typeof(InstanciaUserType))
                    {
                        InstanciaUserType tempa = (InstanciaUserType)atri;
                        if (tempa.lista != null)
                        {
                            foreach (Atributo at in tempa.lista)
                            {
                                if (at.nombre.Equals(id))
                                {
                                    string tipo = at.tipo.ToLower();
                                    if (a == null)
                                    {
                                        if (tipo.Equals("string") || tipo.Equals("date") || tipo.Equals("time"))
                                        {
                                            at.valor = null;
                                        }
                                        else if (!tipo.Equals("int") && !tipo.Equals("boolean") && !tipo.Equals("double") && !tipo.Contains("map") && !tipo.Contains("list") && !tipo.Contains("set"))
                                        {
                                            InstanciaUserType temp = new InstanciaUserType(tipo, null);
                                            at.valor = temp;
                                        }
                                        else
                                        {
                                            mensajes.AddLast(mensa.error("No se le puede asignar al atributo: " + at.nombre + " el valor: null", l, c, "Semantico"));
                                            return(null);
                                        }
                                        return("");
                                    }
                                    else
                                    {
                                        if (op1 != null)
                                        {
                                            if (op1.GetType() == typeof(string) && tipo.Equals("string"))
                                            {
                                                at.valor = (string)op1;
                                            }
                                            else if (op1.GetType() == typeof(int) && tipo.Equals("int"))
                                            {
                                                at.valor = (int)op1;
                                            }
                                            else if (op1.GetType() == typeof(int) && tipo.Equals("double"))
                                            {
                                                at.valor = Convert.ToInt32((Double)op1);
                                            }
                                            else if (op1.GetType() == typeof(Double) && tipo.Equals("double"))
                                            {
                                                at.valor = (Double)op1;
                                            }
                                            else if (op1.GetType() == typeof(Double) && tipo.Equals("int"))
                                            {
                                                at.valor = Convert.ToDouble((int)op1);
                                            }
                                            else if (op1.GetType() == typeof(Boolean) && tipo.Equals("boolean"))
                                            {
                                                at.valor = (Boolean)op1;
                                            }
                                            else if (op1.GetType() == typeof(DateTime) && tipo.Equals("date"))
                                            {
                                                at.valor = (DateTime)op1;
                                            }
                                            else if (op1.GetType() == typeof(TimeSpan) && tipo.Equals("time"))
                                            {
                                                at.valor = (TimeSpan)op1;
                                            }
                                            else if (op1.GetType() == typeof(Map) && tipo.Equals("map"))
                                            {
                                                Map temp  = (Map)op1;
                                                Map valor = (Map)at.valor;
                                                if (valor.id.Equals(temp.id))
                                                {
                                                    at.valor = temp;
                                                    return("");
                                                }
                                                else
                                                {
                                                    mensajes.AddLast(mensa.error("No coincide los tipos: " + valor.id + " con: " + temp.id, l, c, "Semantico"));
                                                    return(null);
                                                }
                                            }
                                            else if (op1.GetType() == typeof(List) && tipo.Equals("list"))
                                            {
                                                List temp  = (List)op1;
                                                List valor = (List)at.valor;
                                                if (valor.id.Equals(temp.id))
                                                {
                                                    at.valor = temp;
                                                    return("");
                                                }
                                                else
                                                {
                                                    mensajes.AddLast(mensa.error("No coincide los tipos: " + valor.id + " con: " + temp.id, l, c, "Semantico"));
                                                    return(null);
                                                }
                                            }
                                            else if (tipo.Equals("set") && op1.GetType() == typeof(Set))
                                            {
                                                Set original = (Set)at.valor;
                                                Set temp     = (Set)op1;
                                                if (original.id.Equals(temp.id))
                                                {
                                                    object resp = temp.buscarRepetidos(mensajes, l, c);
                                                    if (resp == null)
                                                    {
                                                        return(null);
                                                    }
                                                    temp.order();
                                                    ts.setValor(id, temp);
                                                }
                                                else
                                                {
                                                    mensajes.AddLast(mensa.error("No coincide los tipos: " + original.id + " con: " + temp.id, l, c, "Semantico"));
                                                    return(null);
                                                }
                                            }
                                            else if (op1.GetType() == typeof(InstanciaUserType))
                                            {
                                                InstanciaUserType temp = (InstanciaUserType)op1;
                                                if (tipo.Equals(temp.tipo.ToLower()))
                                                {
                                                    at.valor = temp;
                                                }
                                                else
                                                {
                                                    mensajes.AddLast(mensa.error("No se le puede asignar al atributo " + at.nombre + " el valor: " + op1, l, c, "Semantico"));
                                                    return(null);
                                                }
                                            }
                                            else
                                            {
                                                mensajes.AddLast(mensa.error("No se le puede asignar al atributo: " + at.nombre + " el valor: " + op1, l, c, "Semantico"));
                                                return(null);
                                            }
                                            return("");
                                        }
                                        else
                                        {
                                            if (tipo.Equals("string") || tipo.Equals("date") || tipo.Equals("time"))
                                            {
                                                at.valor = null;
                                            }
                                            else if (tipo.Equals("int") || tipo.Equals("double") || tipo.Equals("boolean") || tipo.Equals("map") || tipo.Equals("list") || tipo.Equals("set"))
                                            {
                                                mensajes.AddLast(mensa.error("No se le puede asignar al atributo: " + at.nombre + " el valor: null", l, c, "Semantico"));

                                                return(null);
                                            }
                                            else
                                            {
                                                at.valor = null;
                                            }
                                            return("");
                                        }
                                    }
                                    return(null);
                                }
                            }
                            ambito.listadoExcepciones.AddLast(new Excepcion("exception", "No existe el atributo:" + id));
                            mensajes.AddLast(mensa.error("No existe el atributo:" + id, l, c, "Semantico"));
                        }
                    }
                    else
                    {
                        mensajes.AddLast(mensa.error("Para acceder a un atributo se necesita que sea de tipo USERTYPE no se reconoce: " + atri.ToString(), l, c, "Semantico"));
                    }
                }
                ambito.listadoExcepciones.AddLast(new Excepcion("nullpointerexception", "No se puede asignar un valor a un null"));
            }

            return(null);
        }
Exemplo n.º 9
0
        private InstanciaUserType setearUserType(LinkedList <Attrs> lista, LinkedList <Atributo> valores, string tipoV, LinkedList <User_Types> user_Types)
        {
            InstanciaUserType instancia = new InstanciaUserType(tipoV, new LinkedList <Atributo>());

            foreach (Atributo a in valores)
            {
                Attrs attrs = buscarAttr(lista, a.nombre);
                if (attrs != null)
                {
                    string tipo = attrs.type;
                    if (a.valor != null)
                    {
                        if (tipo.Equals("string") && a.valor.GetType() == typeof(string))
                        {
                            instancia.lista.AddLast(new Atributo(attrs.name, (string)a.valor, tipo));
                        }
                        else if (tipo.Equals("int") && a.valor.GetType() == typeof(int))
                        {
                            instancia.lista.AddLast(new Atributo(attrs.name, (int)a.valor, tipo));
                        }
                        else if (tipo.Equals("double") && a.valor.GetType() == typeof(Double))
                        {
                            instancia.lista.AddLast(new Atributo(attrs.name, (Double)a.valor, tipo));
                        }
                        else if (tipo.Equals("date") && a.valor.GetType() == typeof(DateTime))
                        {
                            instancia.lista.AddLast(new Atributo(attrs.name, (DateTime)a.valor, tipo));
                        }
                        else if (tipo.Equals("time") && a.valor.GetType() == typeof(TimeSpan))
                        {
                            instancia.lista.AddLast(new Atributo(attrs.name, (TimeSpan)a.valor, tipo));
                        }
                        else if (tipo.Equals("counter") && a.valor.GetType() == typeof(int))
                        {
                            instancia.lista.AddLast(new Atributo(attrs.name, (int)a.valor, tipo));
                        }
                        else if (tipo.Contains("list") && a.valor.GetType() == typeof(Set))
                        {
                            string id = tipo.TrimStart('l').TrimStart('i').TrimStart('s').TrimStart('t').TrimStart('>').TrimEnd('>');

                            List temp = new List(id, ((Set)a.valor).datos);
                            instancia.lista.AddLast(new Atributo(attrs.name, temp, tipo));
                        }
                        else if (tipo.Contains("set") && a.valor.GetType() == typeof(Set))
                        {
                            string id = tipo.TrimStart('s').TrimStart('e').TrimStart('t').TrimStart('>').TrimEnd('>');

                            Set temp = (Set)a.valor;
                            temp.order();
                            instancia.lista.AddLast(new Atributo(attrs.name, temp, tipo));
                        }
                        else if (tipo.Contains("map") && a.valor.GetType() == typeof(LinkedList <Atributo>))
                        {
                            string id      = tipo.TrimStart('m').TrimStart('a').TrimStart('p').TrimStart('>').TrimEnd('>');
                            string tipoKey = id.Split(',')[0];
                            LinkedList <Atributo> listatemp = (LinkedList <Atributo>)a.valor;
                            if (listatemp.Count() > 0)
                            {
                                LinkedList <KeyValue> listaRetorno = new LinkedList <KeyValue>();

                                foreach (Atributo at in listatemp)
                                {
                                    KeyValue keyValue = new KeyValue(keyMap(tipoKey, at.nombre), at.valor);
                                    listaRetorno.AddLast(keyValue);
                                }

                                instancia.lista.AddLast(new Atributo(attrs.name, new Map(id, listaRetorno), tipo));
                            }
                            else
                            {
                                instancia.lista.AddLast(new Atributo(attrs.name, new Map(id, new LinkedList <KeyValue>()), tipo));
                            }
                        }
                        else if (a.valor.GetType() == typeof(LinkedList <Atributo>) && tipo.Equals(a.nombre))
                        {
                            LinkedList <Atributo> at = (LinkedList <Atributo>)a.valor;
                            if (at.Count() > 0)
                            {
                                User_Types user = buscarUser(a.nombre, user_Types);
                                if (user != null)
                                {
                                    instancia.lista.AddLast(new Atributo(attrs.name, new InstanciaUserType(tipo, null), tipo));
                                }
                                else
                                {
                                    System.Diagnostics.Debug.WriteLine("No existe usertype: " + tipo);
                                    instancia.lista.AddLast(new Atributo(attrs.name, new InstanciaUserType(tipo, null), tipo));
                                }
                            }
                        }
                    }
                    else
                    {
                        if (tipo.Equals("string") || tipo.Equals("date") || tipo.Equals("time"))
                        {
                            instancia.lista.AddLast(new Atributo(attrs.name, null, tipo));
                        }
                    }
                }
            }
            return(instancia);
        }
Exemplo n.º 10
0
        /*
         * Metodo de la implementacion
         * @ts tabla de simbolos global
         * @user usuario que ejecuta la accion
         * @baseD base de datos donde estamos ejecutando todo
         * @mensajes linkedlist con la salida deseada
         */
        public object ejecutar(TablaDeSimbolos ts, Ambito ambito, TablaDeSimbolos tsT)
        {
            Mensaje             mensa    = new Mensaje();
            object              a        = (valor == null) ? null : valor.ejecutar(ts, ambito, tsT);
            LinkedList <string> mensajes = ambito.mensajes;
            object              res      = ts.getValor(id);
            string              baseD    = ambito.baseD;
            string              existe   = (res == null) ? "si" : res.ToString();

            if (parametro)
            {
                ts.AddLast(new Simbolo(tipo, id));
                if (tipo.Equals("list"))
                {
                    ts.setValor(id, new List("none", new LinkedList <object>()));
                }
                else if (tipo.Equals("set"))
                {
                    ts.setValor(id, new Set("none", new LinkedList <object>()));
                }
                else if (tipo.Equals("map"))
                {
                    ts.setValor(id, new Map("none", new LinkedList <KeyValue>()));
                }
                else if (tipo.Equals("string") || tipo.Equals("int") || tipo.Equals("double") || tipo.Equals("date") || tipo.Equals("time") || tipo.Equals("boolean") || tipo.Equals("cursor"))
                {
                }
                else
                {
                    ts.setValor(id, new InstanciaUserType("none", new LinkedList <Atributo>()));
                }

                return("");
            }
            else if (existe.Equals("none"))
            {
                if (valor == null)
                {
                    if (tipo.Equals("int"))
                    {
                        ts.AddLast(new Simbolo(tipo, id));
                        ts.setValor(id, 0);
                    }
                    else if (tipo.Equals("double"))
                    {
                        ts.AddLast(new Simbolo(tipo, id));
                        ts.setValor(id, 0.0);
                    }
                    else if (tipo.Equals("boolean"))
                    {
                        ts.AddLast(new Simbolo(tipo, id));
                        ts.setValor(id, false);
                    }
                    else if (tipo.Equals("string") || tipo.Equals("date") || tipo.Equals("time"))
                    {
                        ts.AddLast(new Simbolo(tipo, id));
                        ts.setValor(id, null);
                        return("");
                    }
                    else if (tipo.Equals("map"))
                    {
                        mensajes.AddLast(mensa.error("El tipo MAP necesita ser instanciado", l, c, "Semantico"));
                        return(null);
                    }
                    else if (tipo.Equals("list"))
                    {
                        mensajes.AddLast(mensa.error("El tipo LIST necesita ser instanciado", l, c, "Semantico"));
                        return(null);
                    }
                    else if (tipo.Equals("set"))
                    {
                        mensajes.AddLast(mensa.error("El tipo SET necesita ser instanciado", l, c, "Semantico"));
                        return(null);
                    }
                    else if (tipo.Equals("cursor"))
                    {
                        mensajes.AddLast(mensa.error("El tipo CURSOR necesita ser instanciado", l, c, "Semantico"));
                        return(null);
                    }
                    else
                    {
                        BaseDeDatos bd = TablaBaseDeDatos.getBase(baseD);
                        if (bd != null)
                        {
                            if (TablaBaseDeDatos.getUserType(tipo.ToLower(), bd))
                            {
                                ts.AddLast(new Simbolo(tipo, id));
                                ts.setValor(id, new InstanciaUserType(tipo, null));
                            }
                            else
                            {
                                mensajes.AddLast(mensa.error("El tipo " + tipo + " no es un userType en esta base de datos: " + baseD, l, c, "Semantico"));
                                return(null);
                            }
                        }
                        return("");
                    }
                }
                else
                {
                    if (a != null)
                    {
                        if (tipo.Equals("string") && a.GetType() == typeof(string))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (string)a);
                        }
                        else if (tipo.Equals("int") && a.GetType() == typeof(int))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (int)a);
                        }
                        else if (tipo.Equals("int") && a.GetType() == typeof(Double))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, Convert.ToInt32((Double)a));
                        }
                        else if (tipo.Equals("double") && a.GetType() == typeof(Double))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (Double)a);
                        }
                        else if (tipo.Equals("double") && a.GetType() == typeof(int))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, Convert.ToDouble((int)a));
                        }
                        else if (tipo.Equals("boolean") && a.GetType() == typeof(Boolean))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (Boolean)a);
                        }
                        else if (tipo.Equals("date") && a.GetType() == typeof(DateTime))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (DateTime)a);
                        }
                        else if (tipo.Equals("time") && a.GetType() == typeof(TimeSpan))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (TimeSpan)a);
                        }
                        else if (tipo.Equals("map") && a.GetType() == typeof(Map))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (Map)a);
                        }
                        else if (tipo.Equals("list") && a.GetType() == typeof(List))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (List)a);
                        }
                        else if (tipo.Equals("set") && a.GetType() == typeof(Set))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            Set    temp = (Set)a;
                            object resp = temp.buscarRepetidos(mensajes, l, c);
                            if (resp == null)
                            {
                                return(null);
                            }
                            temp.order();
                            ts.setValor(id, temp);
                        }
                        else if (tipo.Equals("cursor") && a.GetType() == typeof(TypeCursor))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, (TypeCursor)a);
                        }
                        else if (a.GetType() == typeof(InstanciaUserType))
                        {
                            InstanciaUserType ins = (InstanciaUserType)a;
                            if (tipo.Equals(ins.tipo.ToLower()))
                            {
                                ts.AddLast(new Simbolo(tipo, id));
                                ts.setValor(id, ins);
                            }
                            else
                            {
                                Mensaje me = new Mensaje();
                                mensajes.AddLast(me.error("La variable " + id + " es de Tipo: " + tipo + " no se puede instanciar al tipo: " + ins.tipo, l, c, "Semantico"));
                            }
                        }
                        else
                        {
                            Mensaje me = new Mensaje();
                            mensajes.AddLast(me.error("La variable " + id + " no se le puede asignar este valor " + a.ToString(), l, c, "Semantico"));
                            return(null);
                        }
                        return("");
                    }
                    else
                    {
                        if (tipo.Equals("string") || tipo.Equals("date") || tipo.Equals("time"))
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, null);
                        }
                        else if (tipo.Equals("int") || tipo.Equals("double") || tipo.Equals("map") || tipo.Equals("set") || tipo.Equals("list") || tipo.Equals("cursor") || tipo.Equals("boolean"))
                        {
                            mensajes.AddLast(mensa.error("No se le puede asignar un valor null al tipo: " + tipo, l, c, "Semantico"));
                            return(null);
                        }
                        else
                        {
                            ts.AddLast(new Simbolo(tipo, id));
                            ts.setValor(id, new InstanciaUserType(tipo, null));
                        }
                        return("");
                    }
                }
            }
            else
            {
                Mensaje me = new Mensaje();
                ambito.listadoExcepciones.AddLast(new Excepcion("objectalreadyexists", "La variable " + id + " ya existe en este ambito"));
                mensajes.AddLast(me.error("La variable " + id + " ya existe en este ambito", l, c, "Semantico"));
            }

            return(null);
        }