Beispiel #1
0
        public override void ejecutar(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }

            if (hijos.Count == 3)
            {
                String nombreToken = lstAtributos.getToken(0).valLower;
                if (nombreToken.Equals("respuesta"))
                {
                    ejecutarRespuesta(simbolo);
                }
                else if (nombreToken.Equals("mostrar"))
                {
                    ejecutarOtros(simbolo);
                }
                else if (nombreToken.Equals("calcular"))
                {
                    ejecutarOtros(simbolo);
                }
            }
            else
            {
                ejecutarHijos(simbolo);
            }
        }
Beispiel #2
0
        public void cargarExtendsPreguntas()
        {
            foreach (elementoClase clase in lstPreguntas)
            {
                if (!clase.extender.valLower.Equals(""))
                {
                    //hay que buscar la clase y cargar los metodos

                    elementoClase tempClase = getClase(clase.extender);
                    if (tempClase == null)
                    {
                        tablaErrores.insertErrorSemantic("No se encuentra la clase: " + clase.extender.val + " de la que se quiere heredar", clase.extender);
                        return;
                    }


                    //heredando metodos, funciones, y constructores
                    clase.lstVariablesGlobales.heredar(tempClase.lstVariablesGlobales.listaPolimorfa);


                    clase.lstMetodo_funcion.heredar(tempClase.lstMetodo_funcion.listaPolimorfa);
                    clase.lstConstructoresHeredados.heredar(tempClase.lstConstructores.listaPolimorfa);
                    //clase.lstVariablesGlobales.heredar(tempClase.lstVariablesGlobales.listaPolimorfa);

                    //cargando
                }
            }
        }
        public override void ejecutar(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }


            //Verificando si tengo como hijo a DECLARAR_VARIABLE_SINVISIBI
            if (hay_DECLARAR_VARIABLE_SINVISIBI(simbolo))
            {
                return;
            }

            // println("llego al contructor");

            token tipo   = getTipo();
            token nombre = getIdentificador();
            //nodoModelo LST_CUERPO = getLST_CUERPO();

            token visbilidad = getVisibilidad(simbolo);

            int dimension             = getDimensiones();
            elementoPolimorfo element = new elementoPolimorfo(visbilidad, tablaSimbolos, tipo, nombre, getVAL(), dimension);

            cargarPolimorfismoHijos(element);
            simbolo.lstVariablesGlobales.insertarElemento(element);
        }
Beispiel #4
0
        public void cargarConstructor(elementoClase simbolo)

        /*
         |----------------------------
         | Constructor
         |----------------------------
         | Este constructor también lo voy a crear manualmente
         | y me va servir para pasar los parametros que vienen en la pregunta.
         */
        {
            if (hayErrores())
            {
                return;
            }

            token nombreClase = lstAtributos.getToken(1);
            token tipo        = new token("vacio");


            elementoPolimorfo element = new elementoPolimorfo(new token("publico"), tablaSimbolos, tipo, nombreClase, new _LST_CUERPO2("LST_CUERPO2", tablaSimbolos), 0);

            _LST_PARAMETROS parametros = (_LST_PARAMETROS)getNodo("LST_PARAMETROS");

            foreach (elementoPolimorfo tempPolimorfo in parametros.getParametros())
            {
                element.insertarParametro(tempPolimorfo.nombre, tempPolimorfo.tipo, tempPolimorfo.dimension);
            }

            simbolo.lstConstructores.insertarElemento(element);
        }
Beispiel #5
0
        public void ejecutarRespuesta(elementoClase simbolo)

        /*
         |----------------------------
         | VISIBILIDAD + tRespuesta + sAbreParent + LST_PARAMETROS + sCierraParent + sAbreLlave + LST_CUERPO + sCierraLlave
         */
        {
            if (hayErrores())
            {
                return;
            }

            token tipo   = new token("vacio");
            token nombre = lstAtributos.getToken(0);


            nombre.val      = "_respuesta";
            nombre.valLower = "_respuesta";



            nodoModelo LST_CUERPO = getLST_CUERPO();
            token      visbilidad = getVisibilidad(simbolo);
            int        dimension  = 0;

            elementoPolimorfo element = new elementoPolimorfo(visbilidad, tablaSimbolos, tipo, nombre, LST_CUERPO, dimension);

            cargarPolimorfismoHijos(element);
            simbolo.lstMetodo_funcion.insertarElemento(element);
        }
Beispiel #6
0
        public void ejecutandoClase(elementoClase clase)
        {
            ///hay que crear una instancia al objeto
            println("Ejecutando el main de " + clase.nombreClase.valLower);
            objetoClase ObjClase = new objetoClase(clase, this);

            ObjClase.ejecutarGlobales();
            ObjClase.ejecutarPrincipal();
            //ObjClase.imprimirTablaEntornos();
        }
Beispiel #7
0
        public void ejecutarHijos(elementoClase elemento)
        {
            if (hayErrores())
            {
                return;
            }

            foreach (nodoModelo temp in hijos)
            {
                // Console.WriteLine("[nodoModelo]EjecutarHijos_padre:" + nombre + "->hijo:" + temp.nombre);
                temp.ejecutar(elemento);
            }
        }
Beispiel #8
0
        public override void ejecutar(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }

            token      tipo       = new token("vacio");
            token      nombre     = new token("principal");
            nodoModelo LST_CUERPO = getLST_CUERPO();

            elementoPolimorfo element = new elementoPolimorfo(new token("publico"), tablaSimbolos, tipo, nombre, LST_CUERPO, 0);

            simbolo.lstPrincipal.insertarElemento(element);
        }
        public token getVisibilidad(elementoClase elem)
        {
            nodoModelo tempNodo = getNodo("VISIBILIDAD");

            if (tempNodo != null)
            {
                _VISIBILIDAD visi = (_VISIBILIDAD)tempNodo;
                return(visi.getVisibilidad());
            }
            else
            {
                //Si no tiene visibilidad retorno la visibilidad de la clase, jake mate ateo!
                return(elem.visibilidad);
            }
        }
        public override void ejecutar(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }

            token      tipo       = new token("vacio");
            token      nombre     = getIdentificador(simbolo.nombreClase);
            nodoModelo LST_CUERPO = getLST_CUERPO();

            elementoPolimorfo element = new elementoPolimorfo(new token("publico"), tablaSimbolos, tipo, nombre, LST_CUERPO, 0);

            cargarPolimorfismoHijos(element);
            simbolo.lstConstructores.insertarElemento(element);
        }
        public Boolean hay_DECLARAR_VARIABLE_SINVISIBI(elementoClase simbolo)
        {
            nodoModelo tempNodo = getNodo("DECLARAR_VARIABLE_SINVISIBI");

            if (tempNodo != null)
            {
                _DECLARAR_VARIABLE_SINVISIBI var = (_DECLARAR_VARIABLE_SINVISIBI)tempNodo;
                var.cargarVariableGlobal(simbolo);

                return(true);
            }

            else
            {
                return(false);
            }
        }
Beispiel #12
0
        public override void ejecutar(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }
            // println("llego al contructor");

            token             tipo       = getTipo();
            token             nombre     = getIdentificador();
            nodoModelo        LST_CUERPO = getLST_CUERPO();
            token             visbilidad = getVisibilidad(simbolo);
            int               dimension  = getDimensiones();
            elementoPolimorfo element    = new elementoPolimorfo(visbilidad, tablaSimbolos, tipo, nombre, LST_CUERPO, dimension);

            cargarPolimorfismoHijos(element);
            simbolo.lstMetodo_funcion.insertarElemento(element);
        }
Beispiel #13
0
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Primer analisis
         |-------------------------------------------------------------------------------------------------------------------
         |
         */
        public override void ejecutar(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }
            // println("llego al contructor");

            token      tipo       = new token("vacio");
            token      nombre     = lstAtributos.getToken(1);
            nodoModelo LST_CUERPO = getLST_CUERPO();
            token      visbilidad = new token("publico");
            int        dimension  = 0;

            elementoPolimorfo element = new elementoPolimorfo(visbilidad, tablaSimbolos, tipo, nombre, LST_CUERPO, dimension);

            cargarPolimorfismoHijos(element);
            simbolo.lstMetodo_funcion.insertarElemento(element);
        }
Beispiel #14
0
        public void ejecutarOtros(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }

            token tipo   = new token("vacio");
            token nombre = lstAtributos.getToken(0);

            nodoModelo LST_CUERPO = getLST_CUERPO();
            token      visbilidad = getVisibilidad(simbolo);
            int        dimension  = 0;

            elementoPolimorfo element = new elementoPolimorfo(visbilidad, tablaSimbolos, tipo, nombre, LST_CUERPO, dimension);

            cargarPolimorfismoHijos(element);
            simbolo.lstMetodo_funcion.insertarElemento(element);
        }
Beispiel #15
0
        public override void ejecutar(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }

            token nombreClase = lstAtributos.getToken(1);
            token extender    = new token("libform");
            token visibilidad = new token("privado");



            elementoClase nuevaClase = new elementoClase(nombreClase, visibilidad, extender, hijos, tablaSimbolos);

            ejecutarHijos(nuevaClase);
            //cargarVariablesGlobales(nuevaClase);
            cargarConstructor(nuevaClase);
            tablaSimbolos.lstPreguntas.Add(nuevaClase);
        }
        /*
         |-------------------------------------------------------------------------------------------------------------------
         | Para cargar las variables globales prro
         |-------------------------------------------------------------------------------------------------------------------
         |
         */


        public void cargarVariableGlobal(elementoClase simbolo)
        {
            if (hayErrores())
            {
                return;
            }


            token tipo   = getTipo();
            token nombre = getIdentificador();
            //nodoModelo LST_CUERPO = getLST_CUERPO();

            token visbilidad = getVisibilidad(simbolo);

            List <int>        dimension = getDimensiones();
            elementoPolimorfo element   = new elementoPolimorfo(visbilidad, tablaSimbolos, tipo, nombre, getVAL(), dimension.Count);

            cargarPolimorfismoHijos(element);
            simbolo.lstVariablesGlobales.insertarElemento(element);
        }
Beispiel #17
0
        //Tengo que alamacenar la clase en la tabla de simbolos
        public override void ejecutar()
        {
            //aqui tengo qu crear una clase real


            if (hayErrores())
            {
                return;
            }

            token nombreClase = getNombre();
            token extender    = getExtender();
            token visibilidad = getVisibilidad();

            elementoClase nuevaClase = new elementoClase(nombreClase, visibilidad, extender, hijos, tablaSimbolos);

            ejecutarHijos(nuevaClase); //aqui cargo ele elmento clase
            //ahora lo ingreso a la tabla de simbolos
            tablaSimbolos.lstClases.Add(nuevaClase);
        }
Beispiel #18
0
        public void cargarVariablesGlobales(elementoClase simbolo)

        /*
         |----------------------------
         | Cargando las variables globales
         |----------------------------
         | Son las variables que voy a enviar en el constructor que tengo
         | que crear manualmente.
         | Aquí cargo los parametros como variables globales, jejejej
         */
        {
            if (hayErrores())
            {
                return;
            }


            _LST_PARAMETROS parametros = (_LST_PARAMETROS)getNodo("LST_PARAMETROS");

            foreach (elementoPolimorfo tempPolimorfo in parametros.getParametros())
            {
                simbolo.lstVariablesGlobales.insertarElemento(tempPolimorfo);
            }
        }
Beispiel #19
0
        //aqui tambien tiene que haber una tabla de entorno prro

        public objetoClase(elementoClase cuerpoClase, tablaSimbolos tabla)
        {
            this.tablaSimbolos = tabla;
            this.cuerpoClase   = cuerpoClase;
            this.tablaEntorno  = new tablaEntornos(tabla, this);
        }
        public itemValor crearPregunta(elementoEntorno elementoEntor)

        /*
         |--------------------------------------------------------------------------
         |  valId + sAbreParent + LST_VAL + sCierraParent;
         |  tNuevo + valId + sAbreParent + LST_VAL + sCierraParent
         |--------------------------------------------------------------------------
         |
         | tengo que crear una nueva clase y cargar los valores globales con sus metdos, funciones, y validar constructores
         | hay que buscar la clase primero
         |
         */
        {
            itemValor retorno = new itemValor();

            retorno.setTypeVacio();


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


            //token tokId = lstAtributos.getToken(1);
            token         tokInstancia = lstAtributos.getToken(0);
            elementoClase temp         = tablaSimbolos.getPregunta(tokInstancia);

            if (temp != null)
            {
                objetoClase ObjClase    = new objetoClase(temp, tablaSimbolos);
                lstValores  lstValores2 = new lstValores();
                //ahora tengo que llamar al constructor, pero digamos que no tiene, jejejeje


                if (hijos.Count > 0)
                {
                    nodoModelo hijo   = hijos[0];
                    _LST_VAL   lstval = (_LST_VAL)hijo;
                    lstValores2 = lstval.getLstValores(elementoEntor);
                    //me tiene que devolver una lista de valores,
                }
                ObjClase.ejecutarConstructor(lstAtributos.getToken(0), 0, lstValores2, ObjClase.tablaEntorno.raiz);
                ObjClase.ejecutarGlobales(); //cargando sus valores globales
                                             // jlk



                // println("========================00     imprimir lo que contiene la pregunta   00 ==================");
                // elementoEntor.imprimir();
                //println("ejecutando constructor de la claes, new objeto()");

                retorno.setValue(ObjClase, lstAtributos.getToken(0).valLower);
                retorno.setTypeObjeto(tokInstancia.valLower);
                //println("Es un objeto");
                return(retorno);
            }
            else
            {
                return(null);
            }
        }
 public token getVisibilidad(elementoClase elem)
 {
     //Si no tiene visibilidad retorno la visibilidad de la clase, jake mate ateo!
     return(elem.visibilidad);
 }
Beispiel #22
0
        public itemValor getValor(elementoEntorno elementoEntor, token tipo)
        {
            itemValor retorno = new itemValor();

            retorno.setTypeNulo();


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

            if (lstAtributos.listaAtributos.Count == 4)
            {
                String item1 = lstAtributos.listaAtributos[0].nombretoken;
                String item2 = lstAtributos.listaAtributos[1].nombretoken;
                if (item1.Equals("nuevo") && item2.Equals("valId"))

                /*
                 |----------------------------
                 |   tNuevo + valId + sAbreParent + LST_VAL + sCierraParent
                 */
                {
                    /*
                     |--------------------------------------------------------------------------
                     | nuevo Objeto()
                     | nuevo valId()
                     |--------------------------------------------------------------------------
                     | tNuevo + valId + sAbreParent + LST_VAL + sCierraParent
                     | tengo que crear una nueva clase y cargar los valores globales con sus metdos, funciones, y validar constructores
                     | hay que buscar la clase primero
                     |
                     */

                    //token tokId = lstAtributos.getToken(1);
                    token         tokInstancia = lstAtributos.getToken(1);
                    elementoClase temp         = tablaSimbolos.getClase(tokInstancia);
                    if (temp != null)
                    {
                        objetoClase ObjClase    = new objetoClase(temp, tablaSimbolos);
                        lstValores  lstValores2 = new lstValores();
                        //ahora tengo que llamar al constructor, pero digamos que no tiene, jejejeje


                        if (hijos.Count > 0)
                        {
                            nodoModelo hijo   = hijos[0];
                            _LST_VAL   lstval = (_LST_VAL)hijo;
                            lstValores2 = lstval.getLstValores(elementoEntor);
                            //me tiene que devolver una lista de valores,
                        }

                        ObjClase.ejecutarGlobales(); //cargando sus valores globales
                                                     // jlk
                        ObjClase.ejecutarConstructor(lstAtributos.getToken(1), 0, lstValores2, ObjClase.tablaEntorno.raiz);
                        //println("ejecutando constructor de la claes, new objeto()");

                        retorno.setValue(ObjClase, lstAtributos.getToken(1).valLower);
                        retorno.setTypeObjeto(tokInstancia.valLower);
                        //println("Es un objeto");

                        return(retorno);
                    }
                    else
                    {
                        tablaSimbolos.tablaErrores.insertErrorSemantic("No se puede  instanaciar la clase:" + tokInstancia.valLower + ", para crear el objeto, debido a que no se existe la clase ", tokInstancia);
                    }


                    return(retorno);
                }
            }

            if (hijos.Count > 0)
            {
                nodoModelo hijo = hijos[0];

                switch (hijo.nombre)
                {
                case "PREGUNTA_NATIVA":

                    _PREGUNTA_NATIVA preg = (_PREGUNTA_NATIVA)hijo;

                    return(preg.getValor(elementoEntor));


                case "TIPO":
                    if (hayErrores())
                    {
                        return(retorno);
                    }

                    /*
                     |--------------------------------------------------------------------------
                     | ARREGLO
                     |--------------------------------------------------------------------------
                     | Hay que mapear las variables para inicializar el array valores de item
                     | Estoy definiendo las dimensiones del arreglo
                     | tNuevo + TIPO + LST_CORCHETES_VAL
                     |
                     |
                     | String[][] hola = new String[3][2];
                     |
                     | String[] jejej = new String[12];
                     | int[][] jeje = { new int[12], { 2, 2 } };
                     |
                     | int[][][] numeros = {{3,3,3},{2,2,2},{1,1,1}, {4,4,4},{5,5,5},{6,6,6}};
                     | hola = jejej;*/
                    nodoModelo tempTipo = getNodo("TIPO");
                    _TIPO      nodoTipo = (_TIPO)tempTipo;
                    retorno.setType(nodoTipo.getTipo().valLower);

                    token      item1 = lstAtributos.listaAtributos[0].tok;
                    nodoModelo temp1 = getNodo("LST_CORCHETES_VAL");
                    if (temp1 != null)
                    {
                        _LST_CORCHETES_VAL lstVal     = (_LST_CORCHETES_VAL)temp1;
                        List <int>         tempLstInt = lstVal.getLstInt(elementoEntor, item1);

                        int dimensionMaxima = 1;
                        foreach (int elemento in tempLstInt)
                        {
                            // println("dimen: " + elemento);
                            if (elemento != 0)
                            {
                                dimensionMaxima = dimensionMaxima * elemento;
                            }
                            else
                            {
                                tablaSimbolos.tablaErrores.insertErrorSemantic("No se puede inicializar una matriz con tamaño 0", item1);
                            }
                        }


                        //llenando la lista de nulos


                        Dictionary <int, itemValor> diccionario = new Dictionary <int, itemValor>();

                        for (int i = 0; i < dimensionMaxima; i++)
                        {
                            diccionario.Add(i, new itemValor());
                        }



                        retorno.setArrayTipo(tempLstInt, diccionario, tipo.valLower);



                        //println("La dimensión mapeada -> indice máximo es " + retorno.arrayValores.Count);
                        //tengo que mapear
                        //  sf
                    }



                    //println(itEntorno.nombre.valLower + "-> tNuevo + TIPO + LST_CORCHETES_VAL");
                    return(retorno);

                case "LST_LLAVES_VAL":

                    /*
                     |--------------------------------------------------------------------------
                     | ARREGLO
                     |--------------------------------------------------------------------------
                     | Le estoy enviando directamente los valores al arreglo
                     | LST_LLAVES_VAL esto retorna=Dictionary<int, itemValor>
                     |
                     */
                    nodoModelo      tempLstLlaves = getNodo("LST_LLAVES_VAL");
                    _LST_LLAVES_VAL nodoLstLlaves = (_LST_LLAVES_VAL)tempLstLlaves;


                    nodoLstLlaves.getArray(tipo, elementoEntor);
                    int arrayLengthMapeado = getDimensionMapeada(nodoLstLlaves.lstDimensiones, tipo);
                    if (arrayLengthMapeado == nodoLstLlaves.diccionario.Count)
                    //se puede agregar correctamente
                    {
                        itemValor retorno2 = new itemValor();
                        retorno2.setType(tipo.valLower);
                        retorno2.arrayValores = nodoLstLlaves.diccionario;
                        retorno2.dimensiones  = nodoLstLlaves.lstDimensiones;
                        return(retorno2);
                    }
                    else
                    {
                        println("Hay problema en las dimensiones del arreglo" + tipo.linea);
                    }



                    return(retorno);

                case "E":

                    /*
                     |--------------------------------------------------------------------------
                     | E
                     |--------------------------------------------------------------------------
                     */
                    _E ope = (_E)hijo;
                    return(ope.getValor(elementoEntor));

                default:
                    println(hijo.nombre + "->No se reconoció la producción :(");
                    return(retorno);
                }
            }
            else

            /*
             |----------------------------
             |   tNulo
             |   tEste
             */
            {
                String item1 = lstAtributos.listaAtributos[0].nombretoken;

                if (item1.Equals("tEste"))
                {
                    itemValor it = new itemValor();
                    it.setTypeObjeto(elementoEntor.este.cuerpoClase.nombreClase.valLower);
                    it.setValue(elementoEntor.este, elementoEntor.este.cuerpoClase.nombreClase.valLower);

                    return(it);
                }
                else
                {
                    /*
                     |--------------------------------------------------------------------------
                     | return nulo
                     |--------------------------------------------------------------------------
                     | tNulo
                     */

                    return(retorno);
                }
            }
        }
Beispiel #23
0
 public override void ejecutar(elementoClase simbolo)
 {
 }
Beispiel #24
0
 /*
  |--------------------------------------------------------------------------
  | Para cargas el cuerpo de la clase
  |--------------------------------------------------------------------------
  |
  */
 public virtual void ejecutar(elementoClase simbolo)
 {
     ejecutarHijos(simbolo);
 }