Beispiel #1
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public virtual itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();
            return(retorno);
        }
Beispiel #2
0
        public itemValor opMenorQue(String ambito, elementoEntorno elem)
        {
            MayorIgualQue mayorIgualQue = new MayorIgualQue(hijo1, hijo2, tabla, signo);

            itemValor retorno = mayorIgualQue.opMayorIgualQue(ambito, elem);

            if (retorno.isTypeBooleano())
            {
                if (retorno.getBooleano())
                {
                    retorno.setValue(false);
                    return(retorno);
                }
                else
                {
                    retorno.setValue(true);
                    return(retorno);
                }
            }
            else
            {
                tabla.tablaErrores.insertErrorSemantic("No se recibió un booleano en" + ambito, signo);
                return(retorno);
            }
        }
        public itemValor opDiferenciacion(String ambito, elementoEntorno elem)
        {
            IgualQue dif = new IgualQue(hijo1, hijo2, tabla, signo);

            itemValor retorno = dif.opIgualacion(ambito, elem);

            if (retorno.isTypeBooleano())
            {
                if (retorno.getBooleano())
                {
                    retorno.setValue(false);
                    return(retorno);
                }
                else
                {
                    retorno.setValue(true);
                    return(retorno);
                }
            }
            else
            {
                tabla.tablaErrores.insertErrorSemantic("No se recibió un booleano en" + ambito, signo);
                return(retorno);
            }
        }
Beispiel #4
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */



        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }


            _E        nodoE = (_E)getNodo("E");
            itemValor valE  = nodoE.getValor(elem);

            String tipo = "cadena";

            Object resul = valE.getValorParseado(tipo);

            if (resul != null)
            {
                String cadena = (String)resul;
                retorno.setValue(cadena);
                return(retorno);
            }
            else
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("No se puede parsear a " + tipo + " el valor", lstAtributos.getToken(0));
                return(retorno);
            }
        }
        public override void ejecutar(elementoEntorno elem)
        {
            if (tabla.hayErrores("lstPrincipal_ejecutar"))
            {
                return;
            }

            if (listaPolimorfa.Count > 0)
            {
                elementoPolimorfo temp = listaPolimorfa[0];
                if (temp.LST_CUERPO.nombre.Equals("LST_CUERPO"))
                {
                    _LST_CUERPO val            = (_LST_CUERPO)temp.LST_CUERPO;
                    itemValor   retornoFuncion = new itemValor();

                    retornoFuncion.setTypeVacio();

                    val.ejecutar(elem);
                    imprimir(elem);
                }
            }
            else
            {
                tabla.tablaErrores.insertErrorSemantic("No se encuentra el main", new token());
            }
        }
Beispiel #6
0
        public itemValor opNot(String ambito, elementoEntorno elem)
        {
            itemValor retorno = new itemValor();
            itemValor val1    = hijo1.getValor(elem);


            if (val1 == null)
            {
                tabla.tablaErrores.insertErrorSemantic("[opLogica]" + ambito + "Hijo1 es null", new token("--"));
                return(retorno);
            }
            try
            {
                /*
                 |--------------------------------------------------------------------------
                 | Entero
                 |--------------------------------------------------------------------------
                 */
                /*
                 * Entero
                 */

                if (val1.isTypeEntero())
                {
                    int val1R = (-1) * val1.getEntero();

                    retorno.setValue(val1R);
                    return(retorno);
                }

                /*
                 |--------------------------------------------------------------------------
                 | Decimal
                 |--------------------------------------------------------------------------
                 */
                /*
                 * Decimal
                 */

                else if (val1.isTypeDecimal())
                {
                    double val1R = (-1) * val1.getDecimal();

                    retorno.setValue(val1R);
                    return(retorno);
                }

                else
                {
                    tabla.tablaErrores.insertErrorSemantic("No se pueden operar [" + ambito + "] " + val1.getTipo(), signo);
                }
            }
            catch (Exception)
            {
                tabla.tablaErrores.insertErrorSemantic("[OpAritemetica]No se pudo efectuar [" + ambito + " ]", signo);
            }

            return(retorno);
        }
Beispiel #7
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public itemValor getValor(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }

            if (hijos.Count != 3)
            {
                return(retorno);
            }



            _VALOR    nodoE       = (_VALOR)hijos[0];
            itemValor valE        = nodoE.getValor(elem, new token(""));
            Object    objetoValor = valE.getValorParseado("booleano");
            Boolean   condicion   = false;

            if (objetoValor != null)
            {
                condicion = (Boolean)objetoValor;
            }
            else
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("La condición devulelta no es de tipo booleano,es de tipo:" + valE.getTipo(), lstAtributos.getToken(0));
                return(retorno);
            }



            _E nodoE2 = (_E)hijos[1];
            _E nodoE3 = (_E)hijos[2];

            if (hayErrores())
            {
                return(retorno);
            }


            itemValor itemVerdadero = nodoE2.getValor(elem);
            itemValor itemFalso     = nodoE3.getValor(elem);



            if (condicion)
            {
                return(itemVerdadero);
            }
            else
            {
                return(itemFalso);
            }
        }
Beispiel #8
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }

            if (hijos.Count != 1)
            {
                return(retorno);
            }



            _E nodoE2 = (_E)hijos[0];

            if (hayErrores())
            {
                return(retorno);
            }


            itemValor itemInicio = nodoE2.getValor(elem);



            if (itemInicio.isTypeFecha())
            {
                return(itemInicio);
            }
            else if (itemInicio.isTypeCadena())
            {
                itemValor tel = new itemValor();
                tel.convertirCadena(itemInicio.getCadena());

                if (tel.isTypeFecha())
                {
                    retorno = tel;
                    return(retorno);
                }
                else
                {
                    tablaSimbolos.tablaErrores.insertErrorSemantic("No se pudo parsear a fecha", lstAtributos.getToken(0));
                    return(retorno);
                }
            }
            else
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("No se pueden parsear a fecha expresiones que no sean cadenas", lstAtributos.getToken(0));
                return(retorno);
            }
        }
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | EJECUCIÓN FINAL
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public override itemRetorno ejecutar(elementoEntorno tablaEntornos)

        /*
         |----------------------------
         | EJECUTAR
         |----------------------------
         | 0 = normal
         | 1 = return;
         | 2 = break
         | 3 = continue
         | 4 = errores
         */
        {
            itemRetorno retorno = new itemRetorno(0);

            if (hayErrores())
            {
                return(retorno);
            }

            _LST_VAL   temp         = (_LST_VAL)getNodo("LST_VAL");
            lstValores listaValores = temp.getLstValores(tablaEntornos);


            if (listaValores.listaValores.Count == 2)

            /*
             |----------------------------
             |  NOMBRE, TEXTO
             */
            {
            }
            else if (listaValores.listaValores.Count == 1)

            /*
             |----------------------------
             |  TEXTO
             */
            {
                itemValor limitInf = listaValores.listaValores[0];
                Object    obj      = limitInf.getValorParseado("cadena");

                if (obj != null)
                {
                    String contenido = (String)obj;
                    contenido = "\n < tr > " +
                                "\n     <td>" + numPregunta + "</td>" + contenido;
                    numPregunta++;
                    _ESCRIBIR_ARCHIVO.contenido = _ESCRIBIR_ARCHIVO.contenido + contenido;
                    escribirArchivo(_ESCRIBIR_ARCHIVO.contenido, _ESCRIBIR_ARCHIVO.nombreArchivo);
                    return(retorno);
                }
            }

            return(retorno);
        }
Beispiel #10
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | EJECUCIÓN FINAL
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public override itemRetorno ejecutar(elementoEntorno tablaEntornos)

        /*
         |----------------------------
         | EJECUTAR
         |----------------------------
         | 0= normal
         | 1 = return;
         | 2 = break
         | 3 = continue
         | 4 = errores
         */
        {
            itemRetorno retorno = new itemRetorno(0);

            if (hayErrores())
            {
                return(retorno);
            }


            if (hijos.Count != 2)
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("Se estan esperando dos parametros, ruta de audio, y valor booleano", lstAtributos.getToken(0));
                return(retorno);
            }


            _E nodo1 = (_E)hijos[0];
            _E nodo2 = (_E)hijos[1];

            itemValor itRuta    = nodo1.getValor(tablaEntornos);
            itemValor itBoolean = nodo2.getValor(tablaEntornos);

            Object objRuta = itRuta.getValorParseado("cadena");
            Object objBool = itBoolean.getValorParseado("booleano");

            if (objRuta == null || objBool == null)
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("Uno de los parámetros no fue cadena y/o booleano", lstAtributos.getToken(0));
                return(retorno);
            }
            else
            {
                string ruta = (string)objRuta;

                ruta = tablaSimbolos.getRutaProyecto() + "\\" + ruta;

                Boolean booleano = (Boolean)objBool;

                frmAudio fdecimal = new frmAudio(tablaEntornos, ruta, booleano);
                fdecimal.ShowDialog();
                return(retorno);
            }
        }
Beispiel #11
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | EJECUCIÓN FINAL
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public override itemRetorno ejecutar(elementoEntorno tablaEntornos)

        /*
         |----------------------------
         | EJECUTAR
         |----------------------------
         | 0= normal
         | 1 = return;
         | 2 = break
         | 3 = continue
         | 4 = errores
         */
        {
            itemRetorno retorno = new itemRetorno(1);

            if (hayErrores())
            {
                return(retorno);
            }


            if (hijos.Count > 0)

            /*
             |----------------------------
             | tRetorno + VALOR + sPuntoComa;
             */
            {
                nodoModelo nodoTemp = getNodo("VALOR");
                if (nodoTemp != null)
                {
                    _VALOR    val       = (_VALOR)nodoTemp;
                    itemValor tempValor = val.getValor(tablaEntornos, new token(""));

                    retorno.setValueRetorno(tempValor);
                    return(retorno);
                }
                else
                {
                    return(retorno);
                }
            }
            else

            /*
             |----------------------------
             |  RETORNO.Rule = tRetorno + sPuntoComa
             |------------------------------
             | Desde aquí ya no sigue la ejecución.
             */
            {
                return(retorno);
            }
        }
Beispiel #12
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }

            if (hijos.Count != 1)
            {
                return(retorno);
            }


            String tipo2 = "entero";


            _E nodoE2 = (_E)hijos[0];

            if (hayErrores())
            {
                return(retorno);
            }

            int inicioVal = 0;



            itemValor itemInicio = nodoE2.getValor(elem);
            Object    inicioTemp = itemInicio.getValorParseado(tipo2);


            if (itemInicio.isTypeDecimal())
            {
                retorno.setValue(Math.Cos(itemInicio.getDecimal()));
                return(retorno);
            }
            else if (inicioTemp != null)
            {
                inicioVal = (int)inicioTemp;
                retorno.setValue(Math.Cos(inicioVal));
                return(retorno);
            }
            else
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("No se puede parsear a entero el valor", lstAtributos.getToken(0));
                return(retorno);
            }
        }
Beispiel #13
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */



        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }

            if (hijos.Count != 1)
            {
                return(retorno);
            }



            _LST_VAL nodoVals = (_LST_VAL)getNodo("LST_VAL");

            if (nodoVals == null)
            {
                return(retorno);
            }

            lstValores listaValroes = nodoVals.getLstValores(elem);

            Random rnd = new Random();

            if (listaValroes.listaValores.Count > 0)
            {
                int       month = rnd.Next(0, listaValroes.listaValores.Count);
                itemValor item  = listaValroes.getItemValor(month);

                if (item.isTypeNulo())
                {
                    retorno.setValue(0);
                    return(retorno);
                }
                else
                {
                    return(item);
                }
            }
            else
            {
                int dice = rnd.Next(0, 2);
                retorno.setValue(dice);
                return(retorno);
            }
        }
Beispiel #14
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | EJECUCIÓN DE PRINCIPAL
         |-------------------------------------------------------------------------------------------------------------------
         |
         */



        public void guardarParametrosEnLaTabla(Dictionary <llaveParametro, elementoParametro> lstParametros, lstValores lstParametros2, elementoEntorno elementoEntor)
        {
            if (lstParametros.Count == lstParametros2.listaValores.Count)
            {
                int i = 0;
                foreach (var dic in lstParametros)
                {
                    itemValor parametro2 = lstParametros2.getItemValor(i);



                    //Console.WriteLine("------------------------");
                    //Console.WriteLine("dic.key.dimension-> " + dic.Key.dimension);
                    //Console.WriteLine("parametro2.dimensiones->" + parametro2.dimensiones.Count);

                    if ((dic.Key.dimension == parametro2.dimensiones.Count) && (itemEntorno.validandoTipo(dic.Value.tipo.valLower, parametro2)))
                    {
                        token tNombre = new token(dic.Key.nombre);
                        token tTipo   = new token(dic.Value.tipo.valLower);

                        //println("guardarParametrosEnLaTabla_ tipo->" + tTipo.valLower);
                        token tVisibilidad = new token("privado");

                        //listado de enteros


                        List <int> listaEntero = new List <int>();

                        for (int j = 0; i < dic.Key.dimension; i++)
                        {
                            listaEntero.Add(-1);
                        }

                        itemEntorno varParametro = new itemEntorno(tNombre, tTipo, parametro2, tVisibilidad, listaEntero, tabla);
                        elementoEntor.insertarEntorno(varParametro);
                    }
                    else
                    {
                        Console.WriteLine("[lstPolimorfismo]guardarParametrosEnLaTabla_Son de diferentes en tipo, o en dimensiones, aunque esto ya se tuvo que validar :/");
                    }

                    i++;
                }
            }
            else
            {
                Console.WriteLine("[lstPolimorfismo]guardarParametrosEnLaTabla_Son de diferentes dimensiones, aunque esto ya se tuvo que validar :/");
            }
        }
Beispiel #15
0
        public lstValores getLstValores(elementoEntorno elemento)
        {
            lstValores retorno = new lstValores();

            foreach (nodoModelo hijo in hijos)
            {
                _VALOR temp = (_VALOR)hijo;

                itemValor temporal1 = temp.getValor(elemento, new token());


                retorno.insertar(temporal1);
            }
            return(retorno);
        }
Beispiel #16
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */



        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }

            if (hijos.Count != 1)
            {
                return(retorno);
            }


            String tipo1 = "booleano";


            _E nodoE1 = (_E)hijos[0];


            if (hayErrores())
            {
                return(retorno);
            }

            Boolean boolVal = false;



            itemValor itemBool   = nodoE1.getValor(elem);
            Object    boolObject = itemBool.getValorParseado(tipo1);


            if (boolObject != null)
            {
                boolVal = (Boolean)boolObject;
                retorno.setValue(boolVal);
                return(retorno);
            }
            else
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("No se puede parsear a booleano el valor", lstAtributos.getToken(0));
                return(retorno);
            }
        }
Beispiel #17
0
        public itemValor calcularTamanio(itemValor itemInicio, elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }



            if (itemInicio.valor != null)
            {
                if (itemInicio.isTypeBooleano() || itemInicio.isTypeEntero() || itemInicio.isTypeDecimal())
                {
                    Object intObject = itemInicio.getValorParseado("entero");
                    if (intObject != null)
                    {
                        int reton = (int)intObject;
                        retorno.setValue(reton);
                        return(retorno);
                    }
                }

                Object cadeObject = itemInicio.getValorParseado("cadena");

                if (cadeObject != null)
                {
                    String caden = (String)cadeObject;

                    retorno.setValue(caden.Length);
                    return(retorno);
                }
                else
                {
                    tablaSimbolos.tablaErrores.insertErrorSemantic("No se puede parsear a cadena para verificar su tamaño", lstAtributos.getToken(0));
                    return(retorno);
                }
            }
            else
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("No se puede parsear un objeto nulo", lstAtributos.getToken(0));
                return(retorno);
            }
        }
Beispiel #18
0
        public Boolean validandoTipo(String tipo1, String tipo2)
        {
            //aquí también hay que verificar las dimensiones


            //if (tipo1.Equals(tipo2) || tipo2.Equals("nulo"))
            itemValor tempIt = new itemValor();

            if (tempIt.getTipoApartirDeString(tipo1).Equals(tipo2) || tipo2.Equals("nulo"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /*
         *
         *  ID_VAR_FUNC.Rule = ID_VAR_FUNC + LST_PUNTOSP
         | tEste + sPunto + valId
         | valId
         | tEste + sPunto + valId + sAbreParent + LST_VAL + sCierraParent
         | valId + sAbreParent + LST_VAL + sCierraParent
         |
         |
         #para los corchetes
         |
         | tEste + sPunto + valId + LST_CORCHETES_VAL
         | valId + LST_CORCHETES_VAL
         | tEste + sPunto + valId + sAbreParent + LST_VAL + sCierraParent + LST_CORCHETES_VAL
         | valId + sAbreParent + LST_VAL + sCierraParent + LST_CORCHETES_VAL;
         |                  ;
         */

        //elementoEntorno elementoEntorno;


        /*
         |-------------------------------------------------------------------------------------------------------------------
         | EJECUCIÓN DESDE EL CUERPO DEL METODO
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public override itemRetorno ejecutar(elementoEntorno tablaEntornos)

        /*
         |----------------------------
         | EJECUTAR
         |----------------------------
         | 0= normal
         | 1 = return;
         | 2 = break
         | 3 = continue
         | 4 = errores
         */
        {
            itemRetorno retorno = new itemRetorno(0);
            itemValor   te2     = getValor(tablaEntornos);

            //println(te2.getTipo() + "|" + te2.nombrePregunta.valLower + "|entorno de ejecutar final ===================================0");


            //if (!(te2.nombrePregunta.valLower.Equals("---") && te2.nombrePregunta.valLower.Equals("") && te2.nombrePregunta.valLower.Equals("--")))
            if (te2.nombrePregunta.esPregunta)
            {
                //println("Estoy ejecutando");
                if (te2 != null)
                {
                    //ahora hay que buscarl la pregunta en la tabla de simbolos prro.
                    itemValor te3 = getValId(te2.nombrePregunta, tablaEntornos);
                    if (te3.isTypeObjeto())
                    {
                        elementoEntorno entor = te3.getObjeto().tablaEntorno.raiz;
                        entor.este.ejecutarMetodoFuncion(new token("ejecutarfinal"), new lstValores(), entor);
                    }
                    else
                    {
                        println("no me retorno un objeto");
                    }
                }
                else
                {
                    println("[Error]sin mvalor fue nulo");
                }
            }

            return(retorno);
        }
Beispiel #20
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */



        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }

            if (hijos.Count > 0)
            {
                return(hijos[0].ope_tipo(elem));
            }

            return(retorno);
        }
Beispiel #21
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        /* public void asignarValor(itemValor destino, itemValor valor, token tokIgual)
         * {
         *
         *   if (destino.dimensiones.Count > 0)
         *   {
         *       if (destino.dimensiones.Count == valor.dimensiones.Count)
         *       {
         *           if (validandoTipo(destino.getTipo(), valor.getTipo()))
         *           {
         *
         *               //aquí se hace la asignación
         *               destino = valor;
         *           }
         *           {
         *               tablaSimbolos.tablaErrores.insertErrorSemantic("Se está intentando guardar en una variable de tipo " + destino.getTipo() + ", un valor de tipo " + valor.getTipo(), tokIgual);
         *
         *           }
         *       }
         *       else
         *       {
         *           tablaSimbolos.tablaErrores.insertErrorSemantic("Se esta recibiendo una dimensión :" + valor.dimensiones.Count + " para asignarlo a la matriz :  de dimension:" + destino.dimensiones.Count, tokIgual);
         *       }
         *   }
         *   else
         *   {
         *       if (valor.dimensiones.Count != 0)
         *       {
         *           tablaSimbolos.tablaErrores.insertErrorSemantic("Se está intentando guardar en la variable  de tipo " + destino.getTipo() + ", una matriz de dimension : " + valor.dimensiones.Count, tokIgual);
         *       }
         *       else if (validandoTipo(destino.getTipo(), valor.getTipo()))
         *       {
         *
         *           //aquí se hace la asignación
         *           destino = valor;
         *       }
         *       else
         *       {
         *           tablaSimbolos.tablaErrores.insertErrorSemantic("Se está intentando guardar en una variable de tipo " + destino.getTipo() + ", un valor de tipo " + valor.getTipo(), tokIgual);
         *       }
         *   }
         *
         * }*/


        public void asignarValor(itemEntorno destino, itemValor valor)
        {
            //validando si lo que estoy esperando es un arreglo

            if (destino.dimension.Count > 0)
            {
                if (destino.dimension.Count == valor.dimensiones.Count)
                {
                    if (validandoTipo(destino.tipo.valLower, valor.getTipo()))
                    {
                        //aquí le asigno el valor
                        destino.valor = valor;
                    }
                    else
                    {
                        tablaSimbolos.tablaErrores.insertErrorSemantic("Se está intentando guardar en :" + destino.nombre.val + " de tipo " + destino.tipo.valLower + ", un valor de tipo " + valor.getTipo(), destino.nombre);
                    }
                }
                else
                {
                    tablaSimbolos.tablaErrores.insertErrorSemantic("Se esta recibiendo :" + valor.dimensiones.Count + " en la matriz : " + destino.nombre.val + " de dimension:" + destino.dimension.Count, destino.nombre);
                }
            }
            else
            {
                if (valor.dimensiones.Count != 0)
                {
                    tablaSimbolos.tablaErrores.insertErrorSemantic("Se está intentando guardar en la variable :" + destino.nombre.val + " de tipo " + destino.tipo.valLower + ", una matriz de dimension : " + valor.dimensiones.Count, destino.nombre);
                }
                else if (validandoTipo(destino.tipo.valLower, valor.getTipo()))
                {
                    //aquí le asigno el valor

                    destino.valor = valor;
                }
                else
                {
                    tablaSimbolos.tablaErrores.insertErrorSemantic("Se está intentando guardar en :" + destino.nombre.val + " de tipo " + destino.tipo.valLower + ", un valor de tipo " + valor.getTipo(), destino.nombre);

                    //error semantico, se está intentando asiganar un valor diferente al declarado por la variable
                }
            }
        }
Beispiel #22
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */


        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }


            String temP = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss");

            retorno.convertirCadena(temP);
            println(temP);

            return(retorno);
        }
Beispiel #23
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */



        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }



            Double pi = Math.PI;

            retorno.setValue(pi);

            return(retorno);
        }
Beispiel #24
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | EJECUCIÓN FINAL
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public override itemRetorno ejecutar(elementoEntorno elementoEntor)

        /*
         |----------------------------
         | EJECUTAR
         |----------------------------
         | 0 = normal
         | 1 = return;
         | 2 = break
         | 3 = continue
         | 4 = errores
         */
        {
            /*
             |----------------------------
             |  tCaso + sAbreParent + E + sCierraParent + tDe + sAbreLlave + CUERPO_CASE + sCierraLlave;
             */
            itemRetorno retorno = new itemRetorno(0);

            if (hayErrores())
            {
                return(retorno);
            }

            _E        nodoE = (_E)getNodo("E");
            itemValor valE  = nodoE.getValor(elementoEntor);

            _CUERPO_CASE    nodoCuerpo = (_CUERPO_CASE)hijos[1];
            elementoEntorno entornoIf  = new elementoEntorno(elementoEntor, tablaSimbolos, "case", elementoEntor.este);
            itemRetorno     cuerpoCase = nodoCuerpo.ejecutar(entornoIf, valE);


            if (cuerpoCase.isRomper())
            //este codigo sirve para eliminar el romper en los nodos, más arriba, y solo se quede en el case
            {
                return(new itemRetorno(0));
            }
            else
            {
                return(retorno);
            }
        }
Beispiel #25
0
        public itemValor getValor(elementoEntorno elemento, token tipo)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();


            if (hayErrores())
            {
                return(retorno);
            }

            if (hijos.Count > 0)
            {
                nodoModelo hijo = hijos[0];
                _VALOR     ope  = (_VALOR)hijo;
                return(ope.getValor(elemento, tipo));
            }

            return(retorno);
        }
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public itemValor getValId(token idVal, elementoEntorno elem)
        // aquí hay que buscar dentro de la tabla de simbolos y devoler el valor, e ir buscando
        // hacia atraás para encontral el id
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();


            itemEntorno et = elem.getItemValor(idVal.valLower);

            if (et != null)
            {
                return(et.valor);
            }
            else
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("La variable : " + idVal.val + "no se encuentra en el ambito correcto para su acceso, no se ha declarado  o no tiene permisos para acceder a ella", idVal);
            }

            return(retorno);
        }
Beispiel #27
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */

        public itemValor getValor(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }

            if (hijos.Count != 1)
            {
                return(retorno);
            }



            _E nodoE2 = (_E)hijos[0];

            if (hayErrores())
            {
                return(retorno);
            }


            itemValor itVal = nodoE2.getValor(elem);

            if (itVal.dimensiones.Count <= 0)
            {
                retorno.setValue(0);
            }
            else
            {
                retorno.setValue(itVal.dimensiones[0]);
            }
            return(retorno);
        }
Beispiel #28
0
        public void asignarValorMatriz(itemEntorno destino, itemValor valor)
        {
            //validando si lo que estoy esperando es un arreglo

            if (destino.dimension.Count > 0)
            {
                if (destino.dimension.Count == destino.lstDimensionesAcceso.Count)
                {
                    if (validandoTipo(destino.tipo.valLower, valor.getTipo()))
                    {
                        int indiceFinal = indiceMapeado(destino.dimension, destino.lstDimensionesAcceso, destino.nombre);
                        if (indiceFinal > -1)
                        {
                            if (indiceFinal < destino.valor.arrayValores.Count)
                            {
                                destino.valor.arrayValores[indiceFinal] = valor;
                            }
                            else
                            {
                                tablaSimbolos.tablaErrores.insertErrorSemantic("No se puede acceder a la posición  de la matriz: " + destino.nombre.val, destino.nombre);
                            }
                        }
                    }
                    else
                    {
                        tablaSimbolos.tablaErrores.insertErrorSemantic("Se está intentando guardar en :" + destino.nombre.val + " de tipo " + destino.tipo.valLower + ", un valor de tipo " + valor.getTipo(), destino.nombre);
                    }
                }
                else
                {
                    tablaSimbolos.tablaErrores.insertErrorSemantic("Se esta recibiendo :" + valor.dimensiones.Count + " en la matriz : " + destino.nombre.val + " de dimension:" + destino.dimension.Count, destino.nombre);
                }
            }
            else
            {
                tablaSimbolos.tablaErrores.insertErrorSemantic("Se está intentando acceder a una matriz  en una variable  :" + destino.nombre.val + "que no lo es.", destino.nombre);
            }
        }
        public itemValor getValor(elementoEntorno elementoEntor, token tipo)
        {
            itemValor retorno = new itemValor();

            if (hayErrores())
            {
                return(retorno);
            }
            //println(hijos[0].nombre);

            nodoModelo temp = getNodo("E");

            if (temp != null)

            /*
             |----------------------------
             | PAR_CORCHETES_VAL.Rule = sAbreCorchete + E + sCierraCorchete;
             */
            {
                _E ret = (_E)temp;
                // ret.getValor(elementoEntor).imprimirVariable();

                ///return ret.getValor(elementoEntor);
                itemValor temporal = ret.getValor(elementoEntor);
                if (temporal.dimensiones.Count > 0)
                {
                    tablaSimbolos.tablaErrores.insertErrorSemantic("El lenguaje no soporta variables, o nuevos arreglos anidados de una forma diferente de {{E,E},{E,E}}: Error en matriz", tipo);
                    return(retorno);
                }
                else
                {
                    //temporal.imprimirVariable();
                    return(temporal);
                }
            }

            return(retorno);
        }
Beispiel #30
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Funciones ope Tipo
         |-------------------------------------------------------------------------------------------------------------------
         |
         */


        public override itemValor ope_tipo(elementoEntorno elem)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();

            if (hayErrores())
            {
                return(retorno);
            }
            if (hijos.Count != 1)
            {
                return(retorno);
            }



            _LST_VAL nodoVals = (_LST_VAL)getNodo("LST_VAL");

            if (nodoVals == null)
            {
                return(retorno);
            }


            _TAM taman = new _TAM("TAM", tablaSimbolos);



            lstValores listaValroes = nodoVals.getLstValores(elem);



            if (listaValroes.listaValores.Count > 0)
            {
                int minimo = 0;

                int i = 0;
                foreach (itemValor itemVal in listaValroes.listaValores)
                {
                    if (i == 0)
                    {
                        itemValor minimoItem = taman.calcularTamanio(itemVal, elem);
                        if (hayErrores())
                        {
                            return(retorno);
                        }

                        minimo = (int)minimoItem.getValorParseado("entero");
                    }
                    else
                    {
                        itemValor minimoItem = taman.calcularTamanio(itemVal, elem);
                        if (hayErrores())
                        {
                            return(retorno);
                        }

                        int enteroAnterio = (int)minimoItem.getValorParseado("entero");
                        if (enteroAnterio < minimo)
                        {
                            minimo = enteroAnterio;
                        }
                    }

                    i++;
                }

                retorno.setValue(minimo);
                return(retorno);
            }
            else
            {
                retorno.setValue(0);
                return(retorno);
            }
        }