/* |------------------------------------------------------------------------------------------------------------------- | EJECUCIÓN FINAL |------------------------------------------------------------------------------------------------------------------- | */ public override itemRetorno ejecutar(elementoEntorno elementoEntorno) /* |---------------------------- | EJECUTAR |---------------------------- | 0= normal | 1 = return; | 2 = break | 3 = continue | 4 = errores */ { itemRetorno retorno = new itemRetorno(0); if (hayErrores()) return retorno; nodoModelo nodoTemp = getNodo("LST_VAL"); _LST_VAL lstParametros = (_LST_VAL)nodoTemp; token nombre = lstAtributos.getToken(1); _ESCRIBIR_ARCHIVO.resetVariables(nombre.val); elementoEntorno.este.ejecutarFormulario(nombre, lstParametros.getLstValores(elementoEntorno), elementoEntorno.este.tablaEntorno.raiz); return retorno; }
/*public opModelo(nodoModelo hijo11, nodoModelo hijo21, tablaSimbolos tabla) * { * this.hijo11 = hijo11; * this.hijo21 = hijo21; * this.tabla = tabla; * }*/ public opModelo(nodoModelo hijo1, nodoModelo hijo2, tablaSimbolos tabla, token signo) { this.hijo1 = (_E)hijo1; this.hijo2 = (_E)hijo2; this.tabla = tabla; this.signo = signo; }
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); }
/* |------------------------------------------------------------------------------------------------------------------- | 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); //ya estoy recibiendo la tabla donde debo trabajar prro if (hayErrores()) { return(retorno); } nodoModelo nodoTemp = getNodo("LST_VAL"); _LST_VAL lstParametros = (_LST_VAL)nodoTemp; // lstValores parametros, elementoEntorno tablaEntorno, token linea tablaEntornos.este.ejecutarConstructorHeredado(lstParametros.getLstValores(tablaEntornos), tablaEntornos, lstAtributos.getToken(0)); return(retorno); }
public void elementoPolimorfo3(tablaSimbolos tabla) { this.tablaSimbolos = tabla; this.tipo = new token(); this.lstParametros = new Dictionary <llaveParametro, elementoParametro>(); this.retorno = new object(); this.LST_CUERPO = new nodoModelo("", tabla); this.nombre = new token(); this.visibilidad = new token("publico"); }
/* |------------------------------------------------------------------------------------------------------------------- | 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); } }
public elementoPolimorfo(token visibilidad, tablaSimbolos tabla, token tipo, token nombre, nodoModelo LST_CUERPO, int dimension) { this.dimension = dimension; this.tablaSimbolos = tabla; this.tipo = tipo; this.nombre = nombre; this.lstParametros = new Dictionary <llaveParametro, elementoParametro>(); this.retorno = new object(); this.LST_CUERPO = LST_CUERPO; this.visibilidad = visibilidad; }
public _E getNodoE() { nodoModelo temp = getNodo("E"); if (temp != null) { return((_E)temp); } else { return(null); } }
public nodoModelo getLST_CUERPO() { nodoModelo tempNodo = getNodo("LST_CUERPO"); if (tempNodo != null) { return(tempNodo); } else { return(new nodoModelo("---", tablaSimbolos)); } }
public _VALOR getNodoVALOR() { nodoModelo temp = getNodo("VALOR"); if (temp != null) { return((_VALOR)temp); } else { return(null); } }
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); } }
private void crearArbol(nodoModelo padre, ParseTreeNode nodoIrony, tablaSimbolos tabla) { nodoModelo hijoNodo = null; if (nodoIrony.ChildNodes.Count == 0) { if (nodoIrony.Token == null) { //no terminal sin hijos //Console.WriteLine("NoTerminal->" + nodoIrony.ToString()); // grafo += nodoIrony.GetHashCode() + "[label=\"" + nodoIrony.ToString() + "\"];\n"; hijoNodo = getNodo(nodoIrony.ToString(), tabla); padre.insertar(hijoNodo); } else { String terminal = escapar(nodoIrony.Token.Value.ToString()); String nombreTerminal = nodoIrony.Term.Name; token tok = new token(terminal, nodoIrony.Token.Location.Line, nodoIrony.Token.Location.Column, nombreArchivo); //Console.WriteLine("[generarArbol]crearArbol:"+nodoIrony.Term.ToString()); padre.lstAtributos.insertar(nombreTerminal, tok); //Console.WriteLine("terminal->" + terminal); //grafo += nodoIrony.GetHashCode() + "[label=\"" + terminal + "\"];\n"; } } else { hijoNodo = getNodo(nodoIrony.ToString(), tabla); //Console.WriteLine("insertando| " + padre.nombre + "->" + hijoNodo.nombre); padre.insertar(hijoNodo); //grafo += nodoIrony.GetHashCode() + "[label=\"" + nodoIrony + "\"];\n"; } foreach (ParseTreeNode hijo in nodoIrony.ChildNodes) { crearArbol(hijoNodo, hijo, tabla); //grafo += nodoIrony.GetHashCode() + "->" + hijo.GetHashCode() + ";\n"; } return; }
public Boolean iniciarAnalisis(String cadena, String nombreArchivo) { //Console.WriteLine("[arbol]rutaProyecto->" + tablaDeSimbolos.getRutaProyecto()); Boolean retorno = false; //GENERANDO EL AST DE IRONY gramatica gramatica = new gramatica(tablaErrores, nombreArchivo); LanguageData lenguaje = new LanguageData(gramatica); Parser parser = new Parser(lenguaje); ParseTree arbol = parser.Parse(cadena); ParseTreeNode raiz = arbol.Root; //GENERANDO EL ARBOL generarArbol generar = new generarArbol(gramatica.nombreArchivo); if (raiz == null) { Console.WriteLine("Arbol Vacio"); retorno = false; } else { // seman.S(raiz); // grafo.generarImagen(raiz); nodoModelo raizArbol = new nodoModelo("raiz", this); raizArbol = generar.generar(raizArbol, raiz, this); //lstAst.Add(raizArbol); //lo guardo en la lista de ast prro //para cargar los imports raizArbol.ejecutar(); //generarImagen(raiz);//aquí se genera el AST retorno = true; } return(retorno); }
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); }
/* |------------------------------------------------------------------------------------------------------------------- | 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); }
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); }
public potencia(nodoModelo hijo1, nodoModelo hijo2, tablaSimbolos tabla, token signo) : base(hijo1, hijo2, tabla, signo) { }
/* |------------------------------------------------------------------------------------------------------------------- | EJECUCIÓN FINAL |------------------------------------------------------------------------------------------------------------------- | */ public override itemRetorno ejecutar(elementoEntorno elementoEntor) /* |---------------------------- | EJECUTAR |---------------------------- | 0= normal | 1 = return; | 2 = break | 3 = continue | 4 = errores */ { itemRetorno retorno = new itemRetorno(0); if (hayErrores()) { return(retorno); } if (hijos[0].nombre.Equals("DECLARAR_VARIABLE_SINVISIBI")) /* |---------------------------- | tPara + sAbreParent + DECLARAR_VARIABLE_SINVISIBI + sPuntoComa + E + sPuntoComa + ASIG_VALOR+ sCierraParent+ sAbreLlave+ LST_CUERPO + sCierraLlave */ { nodoModelo nodotemp = getNodo("DECLARAR_VARIABLE_SINVISIBI"); if (nodotemp == null) { return(retorno); } _DECLARAR_VARIABLE_SINVISIBI decla = (_DECLARAR_VARIABLE_SINVISIBI)nodotemp; decla.ejecutar(elementoEntor); _E nodoE = (_E)getNodo("E"); itemValor valE = nodoE.getValor(elementoEntor); 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); } while (condicion) { elementoEntorno entornoFor = new elementoEntorno(elementoEntor, tablaSimbolos, "para", elementoEntor.este); _LST_CUERPO nodoCuerpo = (_LST_CUERPO)getNodo("LST_CUERPO"); retorno = nodoCuerpo.ejecutar(entornoFor); //analizando el continue, el break, y el return if (retorno.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 if (retorno.isRetorno()) { return(retorno); } else if (retorno.isContinuar()) { return(new itemRetorno(0)); //retorno = new itemRetorno(0); } else if (hayErrores()) { return(retorno); } //i++ _ASIG_VALOR asig = (_ASIG_VALOR)getNodo("ASIG_VALOR"); asig.ejecutar(entornoFor); //volviendo analizar el while nodoE = (_E)getNodo("E"); valE = nodoE.getValor(entornoFor); objetoValor = valE.getValorParseado("booleano"); condicion = (Boolean)objetoValor; } if (retorno.isContinuar()) { return(new itemRetorno(0)); } } else if (hijos[0].nombre.Equals("ASIG_VALOR")) /* |---------------------------- | tPara + sAbreParent + ASIG_VALOR + sPuntoComa + E + sPuntoComa + ASIG_VALOR + sCierraParent + sAbreLlave + LST_CUERPO + sCierraLlave; */ { nodoModelo nodotemp = getNodo("ASIG_VALOR"); if (nodotemp == null) { return(retorno); } _ASIG_VALOR decla = (_ASIG_VALOR)hijos[0]; decla.ejecutar(elementoEntor); _E nodoE = (_E)getNodo("E"); itemValor valE = nodoE.getValor(elementoEntor); 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); } while (condicion) { elementoEntorno entornoFor = new elementoEntorno(elementoEntor, tablaSimbolos, "para", elementoEntor.este); _LST_CUERPO nodoCuerpo = (_LST_CUERPO)getNodo("LST_CUERPO"); retorno = nodoCuerpo.ejecutar(entornoFor); //analizando el continue, el break, y el return if (retorno.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 if (retorno.isRetorno()) { return(retorno); } else if (retorno.isContinuar()) { return(new itemRetorno(0)); //retorno = new itemRetorno(0); } else if (hayErrores()) { return(retorno); } //i++ _ASIG_VALOR asig = (_ASIG_VALOR)hijos[2]; asig.ejecutar(entornoFor); //volviendo analizar el while nodoE = (_E)getNodo("E"); valE = nodoE.getValor(entornoFor); objetoValor = valE.getValorParseado("booleano"); condicion = (Boolean)objetoValor; } if (retorno.isContinuar()) { return(new itemRetorno(0)); } } return(retorno); }
public modulo(nodoModelo hijo1, nodoModelo hijo2, tablaSimbolos tabla, token signo) : base(hijo1, hijo2, tabla, signo) { }
public division(nodoModelo hijo1, nodoModelo hijo2, tablaSimbolos tabla, token signo) : base(hijo1, hijo2, tabla, signo) { }
public opAritmetica(nodoModelo hijo1, nodoModelo hijo2, tablaSimbolos tabla, token signo) : base(hijo1, hijo2, tabla, signo) { }
public negativo(nodoModelo hijo1, tablaSimbolos tabla, token signo) : base(hijo1, tabla, signo) { }
public multiplicacion(nodoModelo hijo1, nodoModelo hijo2, tablaSimbolos tabla, token signo) : base(hijo1, hijo2, tabla, signo) { }
public DiferenteQue(nodoModelo hijo1, nodoModelo hijo2, tablaSimbolos tabla, token signo) : base(hijo1, hijo2, tabla, signo) { }
/* |------------------------------------------------------------------------------------------------------------------- | EJECUCIÓN FINAL |------------------------------------------------------------------------------------------------------------------- | */ public itemValor getValor(elementoEntorno elementoEntorno) { itemValor retorno = new itemValor(); retorno.setTypeVacio(); retorno.setTypeVacio(); //no puede retornar nada, es un metodo mahe if (hayErrores()) { return(retorno); } if (lstAtributos.listaAtributos.Count == 0) /* |---------------------------- | ID_VAR_FUNC + LST_PUNTOSP */ { #region reg1 nodoModelo idVar = getNodo("ID_VAR_FUNC"); if (idVar != null) { nodoModelo lstPuntos = getNodo("LST_PUNTOSP"); if (lstPuntos != null) { _ID_VAR_FUNC temp1 = (_ID_VAR_FUNC)idVar; _LST_PUNTOSP puntos = (_LST_PUNTOSP)lstPuntos; itemValor te1 = temp1.getValor(elementoEntorno); itemValor te2 = puntos.getValor(elementoEntorno, te1); //aquí puedo revisar si fue una pregunta para poder guardarla en el entorno /* if (te2.isTypeObjeto()) * { * if (te2.nombreObjeto.Equals("form")) * { * * //guardando la pregunta dentro de la tabla de simbolos, jejejejejejejejejejejejejeje * itemEntorno sim = new itemEntorno(te1.nombrePregunta, te1.nombrePregunta, te1, new token("publico"), new List<int>(), tablaSimbolos); * elementoEntorno.insertarEntorno(sim); * * * ///ejecuto el metodo ejecutar final, es el que muestra las preguntas * //elementoEntorno.este.ejecutarMetodoFuncion(new token("ejecutarfinal"), new lstValores(), sim.valor.getObjeto().tablaEntorno.raiz); * //println("entorno de ejecutar final ===================================0"); * * // sim.valor.getObjeto().tablaEntorno.raiz.este.ejecutarMetodoFuncion(new token("ejecutarfinal"), new lstValores(), sim.valor.getObjeto().tablaEntorno.raiz); * * * } * } * * if(te1.nombrePregunta.esPregunta) * { * * if (temp1.lstAtributos.listaAtributos.Count > 0) * { * String nombreToken = temp1.lstAtributos.listaAtributos[0].nombretoken; * * if (nombreToken.Equals("valId")) * { * //ahora ya que revisar que se encuentre entre la lsita de preguntas. * // elementoEntorno.este.cuerpoClase.ls * if (tablaSimbolos.esPregunta(temp1.lstAtributos.getToken(0).valLower)) * { * //es pregunta * itemEntorno sim = new itemEntorno(te1.nombrePregunta, te1.nombrePregunta, te1, new token("publico"), new List<int>(), tablaSimbolos); * elementoEntorno.insertarEntorno(sim); * * } * * } * * } * * * } */ return(te2); //tengo que obtener el objeto de id_var_func } } #endregion } else if (lstAtributos.listaAtributos.Count == 1) { if (hijos.Count > 0) /* |---------------------------- | valId + LST_CORCHETES_VAL |------------ | Lst_Corchtes tiene que retornar una lista de tipo entero | */ { #region reg2 token nombreVar = lstAtributos.getToken(0); nodoModelo nodoLstCor = getNodo("LST_CORCHETES_VAL"); if (nodoLstCor != null) { _LST_CORCHETES_VAL lstCorchetes = (_LST_CORCHETES_VAL)nodoLstCor; List <int> listaEntero = lstCorchetes.getLstInt(elementoEntorno, nombreVar); String item1 = lstAtributos.listaAtributos[0].nombretoken; //mapeando el indice if (item1.Equals("valId")) { return(getValIdCorchetes(lstAtributos.listaAtributos[0].tok, elementoEntorno, listaEntero)); } else { println(" valId + LST_CORCHETES_VAL -> No viene val id"); } } #endregion } else /* |---------------------------- | valId */ { #region reg3 String item1 = lstAtributos.listaAtributos[0].nombretoken; if (item1.Equals("valId")) { return(getValId(lstAtributos.listaAtributos[0].tok, elementoEntorno)); } #endregion } } else if (lstAtributos.listaAtributos.Count == 3) { String item1 = lstAtributos.listaAtributos[0].nombretoken; String item2 = lstAtributos.listaAtributos[1].nombretoken; String item3 = lstAtributos.listaAtributos[2].nombretoken; if (item1.Equals("este") && item2.Equals(".") && item3.Equals("valId")) { if (hijos.Count > 0) /* |---------------------------- | tEste + sPunto + valId + LST_CORCHETES_VAL */ { #region reg4 token nombreVar = lstAtributos.getToken(2); nodoModelo nodoLstCor = getNodo("LST_CORCHETES_VAL"); if (nodoLstCor != null) { _LST_CORCHETES_VAL lstCorchetes = (_LST_CORCHETES_VAL)nodoLstCor; List <int> listaEntero = lstCorchetes.getLstInt(elementoEntorno, nombreVar); String item11 = lstAtributos.listaAtributos[2].nombretoken; //mapeando el indice if (item11.Equals("valId")) { return(getValIdCorchetes(lstAtributos.listaAtributos[2].tok, elementoEntorno.este.tablaEntorno.raiz, listaEntero)); } else { println(" tEste + sPunto + valId + LST_CORCHETES_VAL -> No viene val id"); } } #endregion } else /* |---------------------------- | tEste + sPunto + valId */ { #region cuerpo String esteId = lstAtributos.listaAtributos[2].nombretoken; if (esteId.Equals("valId")) { return(getValId(lstAtributos.listaAtributos[2].tok, elementoEntorno.este.tablaEntorno.raiz)); } else { println("(tEste + sPunto + valId) No se encontró valId"); } #endregion } } if (item1.Equals("valId") && item2.Equals("(") && item3.Equals(")")) { if (hijos.Count == 2) /* |---------------------------- | valId + sAbreParent + LST_VAL + sCierraParent + LST_CORCHETES_VAL; |------------------------ * Primero ejecuto el metodo que me tiene que retornar siempre dimension>0 * luego enviarle ese valor, para extraer lo que se quiere */ { #region cuerpo if (hayErrores()) { return(retorno); } String esteId = lstAtributos.listaAtributos[0].nombretoken; if (esteId.Equals("valId")) { //esto es del metodo nodoModelo nodoTemp = getNodo("LST_VAL"); _LST_VAL lstParametros = (_LST_VAL)nodoTemp; itemValor itemValorRetornoMetodo = elementoEntorno.este.ejecutarMetodoFuncion(lstAtributos.getToken(0), lstParametros.getLstValores(elementoEntorno), elementoEntorno.este.tablaEntorno.raiz); //esto es de la parte del arreglo nodoModelo nodoLstCorchetes = getNodo("LST_CORCHETES_VAL"); _LST_CORCHETES_VAL lstCorchetes = (_LST_CORCHETES_VAL)nodoLstCorchetes; List <int> listaEntero = lstCorchetes.getLstInt(elementoEntorno, lstAtributos.listaAtributos[0].tok); if (itemValorRetornoMetodo.dimensiones.Count == listaEntero.Count) //tienen la misma dimension { println("getValCorchetes"); return(getValCorchetes(lstAtributos.getToken(0), elementoEntorno, listaEntero, itemValorRetornoMetodo)); } else //no tienen la misma dimensión. { tablaSimbolos.tablaErrores.insertErrorSemantic("El metodo: " + lstAtributos.getToken(0).val + " no devuelve la misma cantidad de dimensiones que a las que se quiere acceder", lstAtributos.getToken(0)); return(retorno); } } else { println("valId + sAbreParent + LST_VAL + sCierraParent; -> no viene valId"); return(retorno); } #endregion } if (hijos.Count == 1) { String nombreHijo = hijos[0].nombre; if (nombreHijo.Equals("LST_CORCHETES_VAL")) /* |---------------------------- | valId + sAbreParent + sCierraParent + LST_CORCHETES_VAL; */ { #region cuerpo if (hayErrores()) { return(retorno); } String esteId = lstAtributos.listaAtributos[0].nombretoken; if (esteId.Equals("valId")) { //esto es del metodo nodoModelo nodoTemp = getNodo("LST_VAL"); lstValores sinParametros = new lstValores(); itemValor itemValorRetornoMetodo = elementoEntorno.este.ejecutarMetodoFuncion(lstAtributos.getToken(0), sinParametros, elementoEntorno.este.tablaEntorno.raiz); //esto es de la parte del arreglo nodoModelo nodoLstCorchetes = getNodo("LST_CORCHETES_VAL"); _LST_CORCHETES_VAL lstCorchetes = (_LST_CORCHETES_VAL)nodoLstCorchetes; List <int> listaEntero = lstCorchetes.getLstInt(elementoEntorno, lstAtributos.listaAtributos[0].tok); if (itemValorRetornoMetodo.dimensiones.Count == listaEntero.Count) //tienen la misma dimension { println("getValCorchetes"); return(getValCorchetes(lstAtributos.getToken(0), elementoEntorno, listaEntero, itemValorRetornoMetodo)); } else //no tienen la misma dimensión. { tablaSimbolos.tablaErrores.insertErrorSemantic("El metodo: " + lstAtributos.getToken(0).val + " no devuelve la misma cantidad de dimensiones que a las que se quiere acceder", lstAtributos.getToken(0)); return(retorno); } } else { println("valId + sAbreParent + LST_VAL + sCierraParent; -> no viene valId"); return(retorno); } #endregion } else if (nombreHijo.Equals("LST_VAL")) /* |---------------------------- | valId + sAbreParent + LST_VAL + sCierraParent; |------------- | Esto es un metodo | Desde aquí puedo llamar a las preguntas, y tiene mayor prioridad | si me encuentro dentro de un entorno de nombre, formulario, o de nombre grupo */ { #region cuerpo String esteId = lstAtributos.listaAtributos[0].nombretoken; /*if (elementoEntorno.nombre.Equals("formulario") || elementoEntorno.nombre.Equals("grupo")) * * Esto es como el constructor nuevo pregunta() * * { * }*/ //primero busco en las preguntas, luego en los metodos, jejejejeje itemValor ret = crearPregunta(elementoEntorno); if (ret != null) { //eso quiere decir que es una pregunta ret.nombrePregunta = lstAtributos.getToken(0); ret.nombrePregunta.esPregunta = true; itemEntorno sim = new itemEntorno(ret.nombrePregunta, ret.nombrePregunta, ret, new token("publico"), new List <int>(), tablaSimbolos); elementoEntorno.insertarEntorno(sim); return(ret); } //si no lo encuentro como pregunta, sigo la ejecución en busca de un metodo. if (esteId.Equals("valId")) { nodoModelo nodoTemp = getNodo("LST_VAL"); _LST_VAL lstParametros = (_LST_VAL)nodoTemp; return(elementoEntorno.este.ejecutarMetodoFuncion(lstAtributos.getToken(0), lstParametros.getLstValores(elementoEntorno), elementoEntorno.este.tablaEntorno.raiz)); } else { println("valId + sAbreParent + LST_VAL + sCierraParent; -> no viene valId"); } #endregion } } if (hijos.Count == 0) /* |---------------------------- | valId + sAbreParent + sCierraParent; |------------- | Esto es un metodo sin parámetros | hay que buscarlo entre la lista de metodos */ { #region cuerpo String esteId = lstAtributos.listaAtributos[0].nombretoken; if (esteId.Equals("valId")) { lstValores sinParametros = new lstValores(); return(elementoEntorno.este.ejecutarMetodoFuncion(lstAtributos.getToken(0), sinParametros, elementoEntorno.este.tablaEntorno.raiz)); } else { println("valId + sAbreParent + sCierraParent -> no viene valId"); } #endregion } } } else if (lstAtributos.listaAtributos.Count == 5) { String item1 = lstAtributos.listaAtributos[0].nombretoken; String item2 = lstAtributos.listaAtributos[1].nombretoken; String item3 = lstAtributos.listaAtributos[2].nombretoken; if (item1.Equals("este") && item2.Equals(".") && item3.Equals("valId")) { if (hijos.Count == 2) /* |---------------------------- | tEste + sPunto + valId + sAbreParent + LST_VAL + sCierraParent + LST_CORCHETES_VAL; */ { #region cuerpo if (hayErrores()) { return(retorno); } String esteId = lstAtributos.listaAtributos[2].nombretoken; if (esteId.Equals("valId")) { //esto es del metodo nodoModelo nodoTemp = getNodo("LST_VAL"); _LST_VAL lstParametros = (_LST_VAL)nodoTemp; itemValor itemValorRetornoMetodo = elementoEntorno.este.ejecutarMetodoFuncion(lstAtributos.getToken(2), lstParametros.getLstValores(elementoEntorno), elementoEntorno.este.tablaEntorno.raiz); //esto es de la parte del arreglo nodoModelo nodoLstCorchetes = getNodo("LST_CORCHETES_VAL"); _LST_CORCHETES_VAL lstCorchetes = (_LST_CORCHETES_VAL)nodoLstCorchetes; List <int> listaEntero = lstCorchetes.getLstInt(elementoEntorno, lstAtributos.listaAtributos[2].tok); if (itemValorRetornoMetodo.dimensiones.Count == listaEntero.Count) //tienen la misma dimension { println("getValCorchetes"); return(getValCorchetes(lstAtributos.getToken(2), elementoEntorno, listaEntero, itemValorRetornoMetodo)); } else //no tienen la misma dimensión. { tablaSimbolos.tablaErrores.insertErrorSemantic("El metodo: " + lstAtributos.getToken(2).val + " no devuelve la misma cantidad de dimensiones que a las que se quiere acceder", lstAtributos.getToken(2)); return(retorno); } } else { println("tEste + sPunto + valId + sAbreParent + LST_VAL + sCierraParent + LST_CORCHETES_VAL;"); } #endregion } else if (hijos.Count == 1) { if (hijos[0].nombre.Equals("LST_CORCHETES_VAL")) /* |---------------------------- | tEste + sPunto + valId + sAbreParent + sCierraParent + LST_CORCHETES_VAL; */ { #region cuerpo if (hayErrores()) { return(retorno); } String esteId = lstAtributos.listaAtributos[2].nombretoken; if (esteId.Equals("valId")) { //esto es del metodo nodoModelo nodoTemp = getNodo("LST_VAL"); lstValores sinParametros = new lstValores(); itemValor itemValorRetornoMetodo = elementoEntorno.este.ejecutarMetodoFuncion(lstAtributos.getToken(2), sinParametros, elementoEntorno.este.tablaEntorno.raiz); //esto es de la parte del arreglo nodoModelo nodoLstCorchetes = getNodo("LST_CORCHETES_VAL"); _LST_CORCHETES_VAL lstCorchetes = (_LST_CORCHETES_VAL)nodoLstCorchetes; List <int> listaEntero = lstCorchetes.getLstInt(elementoEntorno, lstAtributos.listaAtributos[2].tok); if (itemValorRetornoMetodo.dimensiones.Count == listaEntero.Count) //tienen la misma dimension { println("getValCorchetes"); return(getValCorchetes(lstAtributos.getToken(2), elementoEntorno, listaEntero, itemValorRetornoMetodo)); } else //no tienen la misma dimensión. { tablaSimbolos.tablaErrores.insertErrorSemantic("El metodo: " + lstAtributos.getToken(2).val + " no devuelve la misma cantidad de dimensiones que a las que se quiere acceder", lstAtributos.getToken(2)); return(retorno); } } else { println("tEste + sPunto + valId + sAbreParent + sCierraParent + LST_CORCHETES_VAL"); } #endregion } else if (hijos[0].nombre.Equals("LST_VAL")) /* |---------------------------- | tEste + sPunto + valId + sAbreParent + LST_VAL + sCierraParent */ { #region cuerpo print("tEste + sPunto + valId + sAbreParent + LST_VAL + sCierraParent"); String esteId = lstAtributos.listaAtributos[2].nombretoken; if (esteId.Equals("valId")) { nodoModelo nodoTemp = getNodo("LST_VAL"); _LST_VAL lstParametros = (_LST_VAL)nodoTemp; return(elementoEntorno.este.ejecutarMetodoFuncion(lstAtributos.getToken(2), lstParametros.getLstValores(elementoEntorno), elementoEntorno.este.tablaEntorno.raiz)); } else { println("valId + sAbreParent + LST_VAL + sCierraParent; -> no viene valId"); } } #endregion } else if (hijos.Count == 0) /* |---------------------------- | tEste + sPunto + valId + sAbreParent + sCierraParent */ { #region cuerpo print("tEste + sPunto + valId + sAbreParent + sCierraParent"); String esteId = lstAtributos.listaAtributos[2].nombretoken; if (esteId.Equals("valId")) { nodoModelo nodoTemp = getNodo("LST_VAL"); lstValores sinParametros = new lstValores(); return(elementoEntorno.este.ejecutarMetodoFuncion(lstAtributos.getToken(2), sinParametros, elementoEntorno.este.tablaEntorno.raiz)); } else { println("valId + sAbreParent + LST_VAL + sCierraParent; -> no viene valId"); } #endregion } } } return(retorno); }
public Not(nodoModelo hijo1, tablaSimbolos tabla, token signo) : base(hijo1, tabla, signo) { }
public IgualQue(nodoModelo hijo1, nodoModelo hijo2, tablaSimbolos tabla, token signo) : base(hijo1, hijo2, tabla, signo) { }
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 String rutaDeLaCarpeta = ""; public arbol(FastColoredTextBox cuadro) { tablaDeSimbolos = new tablaSimbolos(cuadro); //tablaDeSimbolos.setRutaProyecto("ruta prueba prro"); raizArbol = new nodoModelo("raiz", tablaDeSimbolos); }
/* |------------------------------------------------------------------------------------------------------------------- | EJECUCIÓN FINAL |------------------------------------------------------------------------------------------------------------------- | */ public itemEntorno getDestino(elementoEntorno elementoEntorno) { itemEntorno retorno = null; if (hayErrores()) { return(retorno); } if (lstAtributos.listaAtributos.Count == 0) /* |---------------------------- | ID_VAR_FUNC + LST_PUNTOSP */ { #region reg1 nodoModelo idVar = getNodo("ID_VAR_FUNC"); if (idVar != null) { nodoModelo lstPuntos = getNodo("LST_PUNTOSP"); if (lstPuntos != null) { _ID_VAR_FUNC temp1 = (_ID_VAR_FUNC)idVar; _LST_PUNTOSP puntos = (_LST_PUNTOSP)lstPuntos; itemValor te1 = temp1.getValor(elementoEntorno); itemEntorno te2 = puntos.getDestino(elementoEntorno, te1); return(te2); //tengo que obtener el objeto de id_var_func } } #endregion } else if (lstAtributos.listaAtributos.Count == 1) { if (hijos.Count > 0) /* |---------------------------- | valId + LST_CORCHETES_VAL |------------ | Lst_Corchtes tiene que retornar una lista de tipo entero | */ { #region reg2 String item1 = lstAtributos.listaAtributos[0].nombretoken; token nombreVar = lstAtributos.getToken(0); if (item1.Equals("valId")) { _LST_CORCHETES_VAL lstCorchetes = (_LST_CORCHETES_VAL)getNodo("LST_CORCHETES_VAL"); return(getEntornoId(lstAtributos.listaAtributos[0].tok, elementoEntorno, lstCorchetes.getLstInt(elementoEntorno, nombreVar))); } #endregion } else /* |---------------------------- | valId */ { String item1 = lstAtributos.listaAtributos[0].nombretoken; if (item1.Equals("valId")) { return(getEntornoId(lstAtributos.listaAtributos[0].tok, elementoEntorno, new List <int>())); } } } else if (lstAtributos.listaAtributos.Count == 3) { String item1 = lstAtributos.listaAtributos[0].nombretoken; String item2 = lstAtributos.listaAtributos[1].nombretoken; String item3 = lstAtributos.listaAtributos[2].nombretoken; if (item1.Equals("este") && item2.Equals(".") && item3.Equals("valId")) { if (hijos.Count > 0) /* |---------------------------- | tEste + sPunto + valId + LST_CORCHETES_VAL */ { #region reg4 String valId = lstAtributos.listaAtributos[2].nombretoken; token nombreVar = lstAtributos.getToken(2); if (valId.Equals("valId")) { _LST_CORCHETES_VAL lstCorchetes = (_LST_CORCHETES_VAL)getNodo("LST_CORCHETES_VAL"); return(getEntornoId(lstAtributos.listaAtributos[2].tok, elementoEntorno.este.tablaEntorno.raiz, lstCorchetes.getLstInt(elementoEntorno, nombreVar))); } #endregion } else /* |---------------------------- | tEste + sPunto + valId */ { String valId = lstAtributos.listaAtributos[2].nombretoken; if (valId.Equals("valId")) { return(getEntornoId(lstAtributos.listaAtributos[2].tok, elementoEntorno.este.tablaEntorno.raiz, new List <int>())); } } } if (item1.Equals("valId") && item2.Equals("(") && item3.Equals(")")) { if (hijos.Count == 2) /* |---------------------------- | valId + sAbreParent + LST_VAL + sCierraParent + LST_CORCHETES_VAL; |------------------------ * Primero ejecuto el metodo que me tiene que retornar siempre dimension>0 * luego enviarle ese valor, para extraer lo que se quiere */ { tablaSimbolos.tablaErrores.insertErrorSemantic("No se le puede asignar un valor a la expresión metodo" + lstAtributos.getToken(0).val + "()[] ", lstAtributos.getToken(0)); } if (hijos.Count == 1) { String nombreHijo = hijos[0].nombre; if (nombreHijo.Equals("LST_VAL")) /* |---------------------------- | valId + sAbreParent + LST_VAL + sCierraParent; |------------- | Esto es un metodo */ { tablaSimbolos.tablaErrores.insertErrorSemantic("No se le puede asignar un valor a la expresión metodo" + lstAtributos.getToken(0).val + "()", lstAtributos.getToken(0)); } } } } else if (lstAtributos.listaAtributos.Count == 5) { String item1 = lstAtributos.listaAtributos[0].nombretoken; String item2 = lstAtributos.listaAtributos[1].nombretoken; String item3 = lstAtributos.listaAtributos[2].nombretoken; if (item1.Equals("este") && item2.Equals(".") && item3.Equals("valId")) { if (hijos.Count == 2) /* |---------------------------- | tEste + sPunto + valId + sAbreParent + LST_VAL + sCierraParent + LST_CORCHETES_VAL; */ { tablaSimbolos.tablaErrores.insertErrorSemantic("No se le puede asignar un valor a la expresión metodo este." + lstAtributos.getToken(0).val + "()[] ", lstAtributos.getToken(0)); } else if (hijos.Count == 1) { if (hijos[0].nombre.Equals("LST_VAL")) /* |---------------------------- | tEste + sPunto + valId + sAbreParent + LST_VAL + sCierraParent */ { tablaSimbolos.tablaErrores.insertErrorSemantic("No se le puede asignar un valor a la expresión metodo este." + lstAtributos.getToken(0).val + "() ", lstAtributos.getToken(0)); } } } } return(retorno); }