--- /dev/null
+header{ \r
+ \r
+ import java.util.*; \r
+\r
+}\r
+\r
+class AnaSem2 extends TreeParser;\r
+options{\r
+ buildAST=true;\r
+ importVocab=Analex;\r
+ importVocab=Anasint;\r
+}\r
+{ \r
+ int cont_dev; // variable contador del numero de instrucciones DEV en un metodo\r
+ \r
+ \r
+ Atr_Expr AS_Literal(AST lit){\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo;\r
+ if(lit == null) return null;\r
+ switch(lit.getType()){\r
+ case LIT_ENTERO: \r
+ tipo = #(#[ENTERO,"entero"]);\r
+ break;\r
+ case LIT_REAL:\r
+ tipo = #(#[REAL,"real"]);\r
+ break;\r
+ case LIT_CAR: \r
+ tipo = #(#[CARACTER,"caracter"]);\r
+ break;\r
+ case CIERTO:\r
+ case FALSO:\r
+ tipo = #(#[LOGICO,"logico"]);\r
+ break;\r
+ default:\r
+ return null;\r
+ }\r
+ result.setTipo(tipo);\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ return result;\r
+ }\r
+ \r
+ Atr_Expr AS_Acceso_Simple(AST dec){\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo = null;\r
+ if (dec == null) return null;\r
+ switch(dec.getType()){\r
+ case MODULO:\r
+ System.out.println("ERROR CT: el tipo es modulo");\r
+ return null;\r
+ case CLASE: //acceso a clase no instanciable\r
+ tipo = dec;\r
+ result.setLVal(false);\r
+ result.setRVal(false);\r
+ break;\r
+ case ATRIBUTO://acceso a un atributo de la propia clase\r
+ tipo = dec.getFirstChild().getNextSibling();\r
+ result.setLVal(true);\r
+ result.setRVal(true);\r
+ break;\r
+ case METODO: //acceso a un metodo de la propia clase\r
+ tipo = dec.getFirstChild();\r
+ result.setLVal(false);\r
+ result.setRVal(false);\r
+ break;\r
+ case PARAMETRO:\r
+ tipo = dec.getFirstChild().getNextSibling();\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ break;\r
+ case VARIABLE_LOCAL:\r
+ tipo = dec.getFirstChild().getNextSibling();\r
+ result.setLVal(true);\r
+ result.setRVal(true);\r
+ break;\r
+ case ERROR:\r
+ return null;\r
+ }\r
+ result.setTipo(tipo);\r
+ return result;\r
+ }\r
+ \r
+ Atr_Expr AS_Acceso_Objeto(Atr_Expr atr_raiz, AST raiz, AST atrib){\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo, tipo_raiz, aux;\r
+ if(atr_raiz == null || raiz == null || atrib ==null) return null;\r
+ //comprobar que el tipo de la raiz sea clase\r
+ tipo_raiz = atr_raiz.getTipo();\r
+ if(tipo_raiz.getType() != CLASE){\r
+ System.out.println("ERROR CT: "+raiz.getFirstChild().getText()+" no es una clase");\r
+ return null;\r
+ }\r
+ //si la raiz es una clase instanciable\r
+ if(raiz.getFirstChild().getNextSibling().getType() == CLASE){\r
+ if(tipo_raiz.getFirstChild().getNextSibling().getType() != NO_INST){\r
+ System.out.println("ERROR CT: "+raiz.getFirstChild().getText()+" es una clase instanciable");\r
+ return null;\r
+ }\r
+ }\r
+ //si la raiz es un objeto\r
+ else{\r
+ if(tipo_raiz.getFirstChild().getNextSibling().getType() != INST){\r
+ System.out.println("ERROR CT: "+raiz.getFirstChild().getText()+" es un objeto de clase no instanciable");\r
+ return null;\r
+ }\r
+ }\r
+ //comprobar que "atrib" sea un atributo o metodo de la clase y ademas sea visible\r
+ aux = tipo_raiz.getFirstChild().getNextSibling().getNextSibling();\r
+ while(aux!= null){\r
+ if(aux.getType() == METODO){\r
+ if(aux.getFirstChild().getFirstChild().equals(atrib))\r
+ break;\r
+ }else{ //atributo\r
+ if(aux.getFirstChild().equals(atrib))\r
+ break;\r
+ }\r
+ aux = aux.getNextSibling();\r
+ }\r
+ if(aux == null){\r
+ System.out.println("ERROR CT: el atributo "+atrib.getText()+" no pertenece a la clase "+raiz.getFirstChild().getText());\r
+ return null;\r
+ }\r
+ if(aux.getFirstChild().getNextSibling().getNextSibling().getType() != VISIBLE){\r
+ System.out.println("ERROR CT: el atributo "+atrib.getText()+" no es visible");\r
+ return null;\r
+ }\r
+ \r
+ //tipo de la expresion\r
+ if(aux.getType() == METODO){\r
+ tipo = aux.getFirstChild();\r
+ result.setLVal(false);\r
+ result.setRVal(false);\r
+ }else{ //atributo\r
+ tipo = aux.getFirstChild().getNextSibling();\r
+ result.setLVal(true);\r
+ result.setRVal(true);\r
+ }\r
+ result.setTipo(tipo);\r
+ return result;\r
+ \r
+ }\r
+ \r
+ //hay que pasarle la raiz para saber el nombre de la raiz cuando no es un metodo\r
+ Atr_Expr AS_Llamada(Atr_Expr atr_raiz, LinkedList expresiones){\r
+ ListIterator it = expresiones.listIterator();\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST pars, par_f, tipo;\r
+ Atr_Expr par_r;\r
+ \r
+ //comprobar que atr_raiz no se a null\r
+ if(atr_raiz == null || expresiones == null){\r
+ return null;\r
+ }\r
+ //comprobar que la raiz sea de tipo prototipo\r
+ if(atr_raiz.getTipo().getType() != PROTOTIPO){\r
+ System.out.println("ERROR CT: "+atr_raiz.getTipo().getText()+" no es un metodo.");\r
+ return null;\r
+ }\r
+ //comprobar que los parametros reales coinciden con los formales\r
+ pars = atr_raiz.getTipo().getFirstChild().getNextSibling();\r
+ par_f = pars.getFirstChild();\r
+ while (it.hasNext() && (par_f != null)){\r
+ par_r = (Atr_Expr)it.next();\r
+ if(! par_f.getFirstChild().getNextSibling().equalsTree(par_r.getTipo())){\r
+ System.out.println("ERROR CT: El numero de parametros en el metodo \""+atr_raiz.getTipo().getFirstChild().getText()+"\" es incorrecto.");\r
+ return null;\r
+ }\r
+ par_f = par_f.getNextSibling();\r
+ }\r
+ if(it.hasNext() && (par_f == null)){\r
+ System.out.println("ERROR CT: El numero de parametros en el metodo \""+atr_raiz.getTipo().getFirstChild().getText()+"\" es incorrecto.");\r
+ return null;\r
+ }\r
+ if(!it.hasNext() && (par_f != null)){\r
+ System.out.println("ERROR CT: El numero de parametros en el metodo \""+atr_raiz.getTipo().getFirstChild().getText()+"\" es incorrecto.");\r
+ return null;\r
+ }\r
+ //el tipo de la expresion es el rango del metodo\r
+ tipo = atr_raiz.getTipo().getFirstChild().getNextSibling().getNextSibling().getFirstChild();\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ result.setTipo(tipo);\r
+ return result;\r
+ }\r
+ \r
+ Atr_Expr AS_Acceso_Tabla(Atr_Expr atr_raiz, LinkedList expresiones){\r
+ if(atr_raiz == null || expresiones == null) return null;\r
+ ListIterator it = expresiones.listIterator();\r
+ Atr_Expr result = new Atr_Expr();\r
+ Atr_Expr aux;\r
+ AST tipo;\r
+ int tam = 0;\r
+ //comprobar que el tipo de la raizes una formacion\r
+ //TODO\r
+ if(atr_raiz.getTipo().getType() != FORMACION){\r
+ System.out.println("ERROR CT: intentando acceder a \""+atr_raiz.getTipo().getText()+"\" como formacion");\r
+ return null;\r
+ }\r
+ //comprobar que el numero de expresiones coincida con el numero de dimensiones\r
+ while(it.hasNext()){\r
+ tam++;\r
+ aux = (Atr_Expr) it.next();\r
+ if(aux == null) return null;\r
+ if(aux.getTipo().getType() != ENTERO){\r
+ System.out.println("ERROR CT: no coinciden el numero de expresiones en el acceso a formacion");\r
+ return null;\r
+ }\r
+ }\r
+ if(tam != atr_raiz.getTipo().getFirstChild().getNumberOfChildren()){\r
+ System.out.println("ERROR CT: no coinciden el numero de expresiones en el acceso a formacion");\r
+ return null;\r
+ }\r
+ tipo = atr_raiz.getTipo().getFirstChild().getNextSibling();\r
+ result.setTipo(tipo);\r
+ result.setLVal(atr_raiz.getLVal());\r
+ result.setRVal(atr_raiz.getRVal());\r
+ return result;\r
+ }\r
+ \r
+ \r
+ \r
+ //AS DE EXPRESIONES\r
+ \r
+ //Expresiones binarias aritmeticas\r
+ Atr_Expr AS_Exp_Bin_Arit(Atr_Expr e1, Atr_Expr e2){\r
+ Atr_Expr result = new Atr_Expr();\r
+ String men="";\r
+ if(e1 == null || e2 == null) return null;\r
+ \r
+ //Comprobamos que e1 y e2 sean consultables\r
+ if(!e1.getLVal() || !e2.getRVal()){\r
+ if (!e2.getRVal()) men="ERROR LR: la expresion no puede aparecer a la derecha de una expresion binaria" ;\r
+ if (!e1.getLVal()) men="ERROR LR: la expresion no puede aparecer a la izquierda de una expresion binaria" ;\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //Comprobamos que e1 y e2 sean numericas y compatibles\r
+ if((e1.getTipo().getType()!=ENTERO) && (e1.getTipo().getType()!=REAL) ||\r
+ (e2.getTipo().getType()!=ENTERO) && (e2.getTipo().getType()!=REAL)){\r
+ System.out.println("ERROR CT: no son expresiones numericas ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")");\r
+ return null;\r
+ }\r
+ if(!e1.getTipo().equals(e2.getTipo())){\r
+ System.out.println("ERROR CT: Los tipos no son compatibles ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")");\r
+ return null;\r
+ }\r
+ \r
+ //Calculamos el tipo\r
+ result.setTipo(e1.getTipo());\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ \r
+ //Expresiones binarias logicas\r
+ Atr_Expr AS_Exp_Bin_Log(Atr_Expr e1, Atr_Expr e2){\r
+ Atr_Expr result = new Atr_Expr();\r
+ String men = "";\r
+ \r
+ if(e1 == null || e2 == null) return null;\r
+ //Comprobar que las expresiones son consultables\r
+ if(!e1.getLVal() || !e2.getRVal()){\r
+ if (!e2.getRVal()) men ="ERROR LR: la expresion no puede aparecer a la derecha de la expresion" ;\r
+ if (!e1.getLVal()) men ="ERROR LR: la expresion "+e1.getTipo().getFirstChild().getText()+" no puede aparecer a la izquierda de la expresion" ;\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //Comprobamos que sean de tipo logico\r
+ if((e1.getTipo().getType()!=LOGICO) || (e2.getTipo().getType()!=LOGICO)){\r
+ if (e1.getTipo().getType()!=LOGICO)\r
+ men = "ERROR CT: la expresion "+e1.getTipo().getFirstChild().getText()+"no es de tipo logico";\r
+ if (e2.getTipo().getType()!=LOGICO)\r
+ men = "ERROR CT: la expresion "+e2.getTipo().getFirstChild().getText()+"no es de tipo logico";\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //Calculamos el tipo\r
+ result.setTipo(e1.getTipo());\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //Expresiones binarias relacionales\r
+ Atr_Expr AS_Exp_Bin_Rel(Atr_Expr e1, Atr_Expr e2, AST operador){\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo;\r
+ String men = "";\r
+ \r
+ if(e1 == null || e2 == null || operador == null) return null;\r
+ //Comprobamos que las expresiones son consultables\r
+ if(!e1.getLVal() || !e2.getRVal()){\r
+ if (!e2.getRVal()) men ="ERROR LR: la expresion no se puede consultar en la expresion binaria" ;\r
+ if (!e1.getLVal()) men ="ERROR LR: la expresion "+e1.getTipo().getFirstChild().getText()+" no puede aparecer a la izquierda en la expresion";\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //No dejamos que se utilicen formaciones y comprobamos la compatibilidad de las expresiones\r
+ if(e1.getTipo().getType()==FORMACION){\r
+ System.out.println("ERROR CT: no puede tener formaciones en expresiones relacionales");\r
+ return null;\r
+ }\r
+ men = "ERROR CT: Los tipos no son compatibles ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")";\r
+ if(!e1.getTipo().equals(e2.getTipo())){\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+\r
+ if((e1.getTipo().getType() == CLASE) && (!e1.getTipo().getFirstChild().equals(e2.getTipo().getFirstChild()))){ //Comparamos las clases por nombre\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //Miramos los grupos de operadores\r
+ if((operador.getType()!=IGUAL && operador.getType()!=DISTINTO) && (e1.getTipo().getType()==CLASE || e1.getTipo().getType()==LOGICO)){\r
+ System.out.println("ERROR CT: el operador \""+operador.getText()+"\" no esta permitido para los tipos usados ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")");\r
+ return null;\r
+ }\r
+ \r
+ //Establecemos el tipo\r
+ tipo = #(#[LOGICO,"logico"]);\r
+ result.setTipo(tipo);\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //Expresiones unarias aritmeticas == MENOS UNARIO\r
+ Atr_Expr AS_Exp_Una_Arit(Atr_Expr e){\r
+ Atr_Expr result = new Atr_Expr();\r
+ String men="";\r
+ \r
+ if(e == null) return null;\r
+ //e tiene que ser consultable\r
+ if(!e.getRVal()){\r
+ men ="ERROR LR: la expresion no es consultable" ;\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //comprobar que e es de tipo numerico\r
+ if( e.getTipo().getType()!=ENTERO && e.getTipo().getType()!=REAL){\r
+ System.out.println("ERROR CT: el menos unario solo puede ser utilizado en expresiones numericas");\r
+ return null;\r
+ }\r
+ \r
+ //Establecemos el tipo\r
+ result.setTipo(e.getTipo());\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //Expresiones unarias logicas == NEGACION\r
+ //Identica a la anterior\r
+ Atr_Expr AS_Exp_Una_Log(Atr_Expr e){\r
+ Atr_Expr result = new Atr_Expr();\r
+ \r
+ if(e == null) return null;\r
+ //e tiene que ser consultable\r
+ if(!e.getRVal()){\r
+ System.out.println("ERROR LR: la expresion no es consultable" );\r
+ return null;\r
+ }\r
+ \r
+ //comprobar que e es de tipo numerico\r
+ if( e.getTipo().getType()!=LOGICO){\r
+ System.out.println("ERROR CT: la negacion solo se puede utilizar con expresiones logicas");\r
+ return null;\r
+ }\r
+ \r
+ //Establecemos el tipo\r
+ result.setTipo(e.getTipo());\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //Instrucciones\r
+ //Asignacion\r
+ void AS_Asignacion(Atr_Expr e1, Atr_Expr e2, AST e3, AST e4){\r
+ //comprobar si alguno es null\r
+ String men = "";\r
+ if(e1==null || e2 == null) return;\r
+ \r
+ //Comprobamos la consultabilidad de las expresiones\r
+ if(!e1.getLVal() || !e2.getRVal()){\r
+ if (!e2.getRVal())\r
+ men ="ERROR LR: la expresion "+e4.getFirstChild().getText()+" no puede aparecer a la derecha de una asignacion." ;\r
+ if (!e1.getLVal()) men ="ERROR LR: el "+e3.getFirstChild().getNextSibling().getText()+" "+e3.getFirstChild().getText()+" no puede aparecer a la izquierda de una asignacion." ;\r
+ System.out.println(men);\r
+ return;\r
+ }\r
+ \r
+ //No dejamos asignar formaciones y comprobamos la compatibilidad de tipos\r
+ if(e1.getTipo().getType()==FORMACION){\r
+ System.out.println("ERROR CT: no dejamos asignar formaciones");\r
+ }\r
+ men = "ERROR CT: Los tipos no son compatibles ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")";\r
+ if(!e1.getTipo().equals(e2.getTipo())){\r
+ System.out.println(men);\r
+ }\r
+ if((e1.getTipo().getType() == CLASE) && (!e1.getTipo().getFirstChild().equals(e2.getTipo().getFirstChild()))){ //Comparamos las clases por nombre\r
+ System.out.println(men);\r
+ }\r
+ }\r
+ \r
+ //Condiciones\r
+ void AS_Condicional(Atr_Expr e){\r
+ String men = "";\r
+ if (e == null) return;\r
+ if(!e.getRVal()){\r
+ men ="ERROR LR: la expresion no es consultable" ;\r
+ System.out.println(men);\r
+ return;\r
+ }\r
+ \r
+ //Comprobamos que es de tipo logico\r
+ if(e.getTipo().getType()!=LOGICO){\r
+ System.out.println("ERROR CT: no es un tipo logico");\r
+ }\r
+ }\r
+ \r
+ //Instruccion de devolucion\r
+ int AS_Devolucion(AST tipo_dev, Atr_Expr e, int cont){\r
+ String men = "";\r
+// String men = "ERROR CT: Los tipos no son compatibles (entero y real)"\r
+ if(tipo_dev == null || e == null) return cont+1;\r
+ //Comprobamos que el metodo sea funcional\r
+\r
+ if(cont == -1){\r
+ System.out.println("ERROR CT: el metodo no es funcional");\r
+ return -1;\r
+ }\r
+\r
+ //Comprobar que la expresion e es consultable\r
+ if(!e.getRVal()){\r
+ System.out.println("ERROR CT: la expresion no es consultable, no se puede devolver");\r
+ }\r
+ \r
+ men = "ERROR CT: Los tipos no son compatibles ("+e.getTipo().getText()+" y "+tipo_dev.getText()+")";\r
+ //Comprobamos que el tipo de la expresion es compatible con el tipo que se devuelve\r
+ if(!e.getTipo().equals(tipo_dev)){\r
+ System.out.println(men);\r
+ }\r
+ if(tipo_dev.getType()==CLASE && (!tipo_dev.getFirstChild().equals(e.getTipo().getFirstChild()))){\r
+ System.out.println(men);\r
+ }\r
+ \r
+ if(tipo_dev.getType()==FORMACION && (!tipo_dev.equals(e.getTipo()))){\r
+ System.out.println(men);\r
+ }\r
+ \r
+ return cont + 1;\r
+ }\r
+ \r
+ \r
+ Atr_Expr AS_Crear(Atr_Expr as, AST clase){\r
+ if (as == null || clase == null){\r
+ System.out.println("ERROR CT: no se puede crear");\r
+ return null;\r
+ }\r
+ //comprobar que el tipo de la variable es el mismo que el del interior de crear\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo = as.getTipo();\r
+ if(tipo.getType() != CLASE){\r
+ System.out.println("ERROR CT: no es una clase");\r
+ return null;\r
+ }\r
+ if(!(tipo.getFirstChild().getNextSibling().getType() == INST)){\r
+ System.out.println("ERROR CT: la clase no es instanciable");\r
+ return null;\r
+ }\r
+ AST tipo_var = tipo.getFirstChild();\r
+ AST interior = clase;\r
+ if(!tipo_var.getText().equals(interior.getText())){\r
+ if(interior.getType() == ACCESO_SIMPLE)\r
+ System.out.println("ERROR CT: Los tipos no son compatibles ("+tipo_var.getText()+" y "+interior.getFirstChild().getText()+")");\r
+ else\r
+ System.out.println("ERROR CT: Los tipos no son compatibles ("+tipo_var.getText()+" y "+interior.getText()+")");\r
+ return null;\r
+ }\r
+\r
+ result.setLVal(false);\r
+ result.setRVal(false);\r
+ //el tipo es el de la variable\r
+ result.setTipo(tipo);\r
+ \r
+ return result;\r
+ } \r
+ \r
+ //AS Escribir\r
+ void AS_Escribir(Atr_Expr e, AST exp){\r
+ if (e == null){\r
+ if(exp.getType() == ACCESO_SIMPLE)\r
+ System.out.println("ERROR CT: no se puede escribir "+ exp.getFirstChild().getText());\r
+ else\r
+ System.out.println("ERROR CT: no se puede escribir "+ exp.getText());\r
+ return;\r
+ }\r
+ //Comprobamos que la expresion se pueda consultar\r
+ if(!e.getRVal()){\r
+ System.out.println("ERROR CT: la expresion no es consultable, no se puede escribir");\r
+ }\r
+ }\r
+\r
+ \r
+ //AS Entero A Real\r
+ Atr_Expr AS_Entero_A_Real(Atr_Expr e1){\r
+ Atr_Expr result = new Atr_Expr();\r
+ if (e1 == null) return null;\r
+ AST tipo = e1.getTipo();\r
+ if(tipo.getType() != ENTERO){\r
+ System.out.println("ERROR CT: El tipo del parametro del operador enteroareal es incorrecto.");\r
+ return null;\r
+ }\r
+ result.setTipo(#(#[REAL,"real"]));\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ return result;\r
+ }\r
+ Atr_Expr AS_Real_A_Entero(Atr_Expr e1){\r
+ Atr_Expr result = new Atr_Expr();\r
+ \r
+ if (e1 == null) return null;\r
+ AST tipo = e1.getTipo();\r
+ if(tipo.getType() != REAL){\r
+ System.out.println("ERROR CT: El tipo del parametro del operador realaentero es incorrecto.");\r
+ return null;\r
+ }\r
+ result.setTipo(#(#[ENTERO,"entero"]));\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ return result;\r
+ }\r
+ \r
+ \r
+}\r
+\r
+// ========= FIN DE DECLARACION DE FUNCIONES\r
+\r
+declaracion_modulo: #(MODULO nombre_modulo definicion_modulo);\r
+\r
+nombre_modulo : IDENT ;\r
+\r
+definicion_modulo:\r
+ (importacion)?\r
+ (exportacion)+\r
+ (implementacion)?\r
+;\r
+\r
+importacion : #(IMPORTACION lista_ident);\r
+lista_ident: (IDENT)+;\r
+\r
+exportacion : #(EXPORTACION lista_declaraciones_clases);\r
+\r
+implementacion : #(IMPLEMENTACION lista_declaraciones_clases);\r
+\r
+\r
+lista_declaraciones_clases: (declaracion_clase)*\r
+;\r
+\r
+declaracion_clase : #(CLASE nombre_clase cualificador_clase definicion_clase)\r
+;\r
+\r
+cualificador_clase : INST | NO_INST ;\r
+\r
+nombre_clase : IDENT ;\r
+\r
+definicion_clase : declaraciones_elementos_clase\r
+;\r
+\r
+declaraciones_elementos_clase : (declaracion_elemento_clase)* ;\r
+\r
+declaracion_elemento_clase :\r
+#(METODO declaracion_metodo cualificador_elemento_clase)\r
+| #(ATRIBUTO IDENT tipo cualificador_elemento_clase)\r
+;\r
+\r
+cualificador_elemento_clase: OCULTO | VISIBLE ;\r
+\r
+declaracion_metodo {AST tipodev;} : tipodev =prototipo_metodo definicion_metodo[tipodev]\r
+{ if (cont_dev == 0){\r
+ System.out.println("ERROR: Metodo funcional que no devuelve nada");\r
+ System.exit(-1);\r
+ }\r
+} ;\r
+\r
+prototipo_metodo returns [AST tipodev=null]: #(PROTOTIPO IDENT #(PARAMETROS\r
+declaracion_parametros)\r
+#(RESULTADO\r
+( t: tipo {cont_dev = 0; // inicializa el contador de instrucciones DEV\r
+tipodev = t; }\r
+| v: VACIO {cont_dev = -1; // marca a -1 para indicar que es un procedimiento\r
+tipodev = v; }\r
+)))\r
+;\r
+\r
+declaracion_parametros : (declaracion_parametro)* ;\r
+\r
+declaracion_parametro : #(PARAMETRO IDENT tipo) ;\r
+\r
+definicion_metodo [AST tipodev]: #(DEFINICION #(VARIABLES_LOCALES declaracion_variables_locales) #(INSTRUCCIONES instrucciones[tipodev]))\r
+;\r
+\r
+declaracion_variables_locales : (declaracion_variable_local)* ;\r
+\r
+declaracion_variable_local : #(VARIABLE_LOCAL IDENT tipo) ;\r
+\r
+declaracion_error : ERROR;\r
+\r
+instrucciones [AST tipodev] : (instruccion[tipodev])* ;\r
+\r
+instruccion [AST tipodev] : #(INSTRUCCION ( instruccion_simple[tipodev] | instruccion_compuesta[tipodev]))\r
+;\r
+\r
+instruccion_simple [AST tipodev] : crear\r
+| llamada_metodo\r
+| escribir\r
+| asignacion\r
+| retorno [tipodev]\r
+;\r
+\r
+crear{Atr_Expr e1;} : #(CREAR e1=expresion e2:expresion)\r
+{AS_Crear(e1,#e2);}\r
+;\r
+\r
+escribir{Atr_Expr e1;}: #(ESCRIBIR e1=e:expresion)\r
+{AS_Escribir(e1, #e);};\r
+\r
+instruccion_compuesta [AST tipodev] :\r
+condicion [tipodev]\r
+| iteracion [tipodev]\r
+;\r
+\r
+asignacion {Atr_Expr e1, e2;}: #(ASIGNACION e1=e3:expresion e2=e4:expresion )\r
+{ AS_Asignacion(e1,e2,#e3,#e4);\r
+};\r
+\r
+retorno [AST tipodev] {Atr_Expr e;}: #(DEV e=expresion)\r
+{/*AS_Devolucion(tipodev, e);\r
+cont_dev++;*/\r
+cont_dev=AS_Devolucion(tipodev,e,cont_dev);\r
+}\r
+;\r
+\r
+llamada_metodo {Atr_Expr a, res; LinkedList l;}:\r
+#(LLAMADA a=acceso #(EXPRESIONES l=lista_expresiones))\r
+{res=AS_Llamada(a,l);\r
+ if (res != null && res.getTipo().getType() != VACIO){\r
+ System.out.println("ERROR: Llamada a funcion sin asignar valor devuelto.");\r
+ System.exit(1); \r
+ } \r
+} \r
+;\r
+\r
+lista_expresiones returns [LinkedList l= new LinkedList()] {Atr_Expr e;}:\r
+(e=expresion {l.add(e);})* ;\r
+\r
+condicion [AST tipodev] {Atr_Expr e;} : #(SI e=expresion #(INSTRUCCIONES instrucciones[tipodev])\r
+(#(INSTRUCCIONES instrucciones[tipodev]))?)\r
+{AS_Condicional(e);\r
+}\r
+;\r
+\r
+iteracion [AST tipodev] {Atr_Expr e;} : #(MIENTRAS e=expresion #(INSTRUCCIONES\r
+instrucciones[tipodev])) {AS_Condicional(e);\r
+}\r
+;\r
+\r
+expresion returns [Atr_Expr res=null] {Atr_Expr e1,e2; LinkedList l;}:\r
+#(O e1=expresion e2=expresion) {res=AS_Exp_Bin_Log( e1, e2);\r
+}\r
+| #(Y e1=expresion e2=expresion) {res=AS_Exp_Bin_Log( e1, e2);\r
+}\r
+| #(NO e1=expresion) {res=AS_Exp_Una_Log( e1);\r
+}\r
+| #(op1:MAYOR e1=expresion e2=expresion) {res=AS_Exp_Bin_Rel( e1, e2, op1);\r
+}\r
+| #(op2:MAYOR_IGUAL e1=expresion e2=expresion) {res=AS_Exp_Bin_Rel( e1, e2, op2);\r
+}\r
+| #(op3:MENOR e1=expresion e2=expresion) {res=AS_Exp_Bin_Rel( e1, e2, op3);\r
+}\r
+| #(op4:MENOR_IGUAL e1=expresion e2=expresion) {res=AS_Exp_Bin_Rel( e1, e2, op4);\r
+}\r
+| #(op5:IGUAL e1=expresion e2=expresion) {res=AS_Exp_Bin_Rel( e1, e2, op5);\r
+}\r
+| #(op6:DISTINTO e1=expresion e2=expresion) {res=AS_Exp_Bin_Rel( e1, e2, op6);\r
+}\r
+| #(MAS e1=expresion e2=expresion) {res=AS_Exp_Bin_Arit( e1, e2);\r
+}\r
+| #(MENOS e1=expresion e2=expresion) {res=AS_Exp_Bin_Arit( e1, e2);\r
+}\r
+| #(MENOSUNARIO e1=expresion) {res=AS_Exp_Una_Arit( e1);\r
+}\r
+| #(POR e1=expresion e2=expresion) {res=AS_Exp_Bin_Arit( e1, e2);\r
+}\r
+| #(DIVISION e1=expresion e2=expresion) {res=AS_Exp_Bin_Arit( e1, e2);\r
+}\r
+| #(LLAMADA e1=acceso #(EXPRESIONES l=lista_expresiones))\r
+{res=AS_Llamada( e1, l);\r
+if (res != null){\r
+ if (res.getTipo().getType() == VACIO){\r
+ System.out.println("ERROR: No se puede recoger el valor devuelto por un procedimiento (no devuelve nada).");\r
+ System.exit(1);\r
+ }\r
+}\r
+}\r
+| #(ACCESO_TABLA e1=acceso #(EXPRESIONES l=lista_expresiones_nv))\r
+{res=AS_Acceso_Tabla( e1, l);\r
+}\r
+| e1=acceso {res=e1;}\r
+\r
+| i:LIT_ENTERO {res=AS_Literal( i);}\r
+| j:LIT_REAL {res=AS_Literal( j);}\r
+| k:LIT_CAR {res=AS_Literal( k);}\r
+| m:CIERTO {res=AS_Literal( m);}\r
+| n:FALSO {res=AS_Literal( n);}\r
+| #(ENTERO_A_REAL e1=expresion) {res = AS_Entero_A_Real(e1);}\r
+| #(REAL_A_ENTERO e1=expresion) {res = AS_Real_A_Entero(e1);}\r
+| ERROR\r
+;\r
+\r
+acceso returns [Atr_Expr res=null] {Atr_Expr e;}:\r
+e=acceso_simple {res=e;}\r
+| #(ACCESO_OBJETO e=r:acceso_simple a:IDENT) {\r
+ res=AS_Acceso_Objeto( e, r, a);\r
+}\r
+;\r
+\r
+acceso_simple returns [Atr_Expr res=null]:\r
+#(ACCESO_SIMPLE IDENT d:declaracion_acceso) {res=AS_Acceso_Simple(#d);}\r
+;\r
+\r
+declaracion_acceso: declaracion_modulo\r
+| declaracion_clase\r
+| declaracion_elemento_clase\r
+| declaracion_parametro\r
+| declaracion_variable_local\r
+| declaracion_error\r
+;\r
+\r
+lista_expresiones_nv returns [LinkedList l= new LinkedList()] {Atr_Expr e;}:\r
+(e=expresion {l.add(e);})+ ;\r
+\r
+tipo :\r
+tipo_predefinido_simple\r
+| tipo_predefinido_compuesto\r
+| IDENT\r
+| declaracion_error\r
+;\r
+\r
+tipo_predefinido_simple :\r
+ENTERO\r
+| REAL\r
+| LOGICO\r
+| CARACTER\r
+;\r
+\r
+tipo_predefinido_compuesto : formacion\r
+;\r
+\r
+formacion {AST t=null;}: #(FORMACION #(LISTA_ENTEROS lista_enteros)(tipo_predefinido_simple))\r
+;\r
+\r
+lista_enteros : (LIT_ENTERO)+ ;
\ No newline at end of file
--- /dev/null
+// $ANTLR : "AnaSem2.g" -> "AnaSem2.java"$
+ \r
+ \r
+ import java.util.*; \r
+\r
+
+import antlr.TreeParser;
+import antlr.Token;
+import antlr.collections.AST;
+import antlr.RecognitionException;
+import antlr.ANTLRException;
+import antlr.NoViableAltException;
+import antlr.MismatchedTokenException;
+import antlr.SemanticException;
+import antlr.collections.impl.BitSet;
+import antlr.ASTPair;
+import antlr.collections.impl.ASTArray;
+
+
+public class AnaSem2 extends antlr.TreeParser implements AnaSem2TokenTypes
+ {
+ \r
+ int cont_dev; // variable contador del numero de instrucciones DEV en un metodo\r
+ \r
+ \r
+ Atr_Expr AS_Literal(AST lit){\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo;\r
+ if(lit == null) return null;\r
+ switch(lit.getType()){\r
+ case LIT_ENTERO: \r
+ tipo = (AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(ENTERO,"entero")));\r
+ break;\r
+ case LIT_REAL:\r
+ tipo = (AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(REAL,"real")));\r
+ break;\r
+ case LIT_CAR: \r
+ tipo = (AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(CARACTER,"caracter")));\r
+ break;\r
+ case CIERTO:\r
+ case FALSO:\r
+ tipo = (AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(LOGICO,"logico")));\r
+ break;\r
+ default:\r
+ return null;\r
+ }\r
+ result.setTipo(tipo);\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ return result;\r
+ }\r
+ \r
+ Atr_Expr AS_Acceso_Simple(AST dec){\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo = null;\r
+ if (dec == null) return null;\r
+ switch(dec.getType()){\r
+ case MODULO:\r
+ System.out.println("ERROR CT: el tipo es modulo");\r
+ return null;\r
+ case CLASE: //acceso a clase no instanciable\r
+ tipo = dec;\r
+ result.setLVal(false);\r
+ result.setRVal(false);\r
+ break;\r
+ case ATRIBUTO://acceso a un atributo de la propia clase\r
+ tipo = dec.getFirstChild().getNextSibling();\r
+ result.setLVal(true);\r
+ result.setRVal(true);\r
+ break;\r
+ case METODO: //acceso a un metodo de la propia clase\r
+ tipo = dec.getFirstChild();\r
+ result.setLVal(false);\r
+ result.setRVal(false);\r
+ break;\r
+ case PARAMETRO:\r
+ tipo = dec.getFirstChild().getNextSibling();\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ break;\r
+ case VARIABLE_LOCAL:\r
+ tipo = dec.getFirstChild().getNextSibling();\r
+ result.setLVal(true);\r
+ result.setRVal(true);\r
+ break;\r
+ case ERROR:\r
+ return null;\r
+ }\r
+ result.setTipo(tipo);\r
+ return result;\r
+ }\r
+ \r
+ Atr_Expr AS_Acceso_Objeto(Atr_Expr atr_raiz, AST raiz, AST atrib){\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo, tipo_raiz, aux;\r
+ if(atr_raiz == null || raiz == null || atrib ==null) return null;\r
+ //comprobar que el tipo de la raiz sea clase\r
+ tipo_raiz = atr_raiz.getTipo();\r
+ if(tipo_raiz.getType() != CLASE){\r
+ System.out.println("ERROR CT: "+raiz.getFirstChild().getText()+" no es una clase");\r
+ return null;\r
+ }\r
+ //si la raiz es una clase instanciable\r
+ if(raiz.getFirstChild().getNextSibling().getType() == CLASE){\r
+ if(tipo_raiz.getFirstChild().getNextSibling().getType() != NO_INST){\r
+ System.out.println("ERROR CT: "+raiz.getFirstChild().getText()+" es una clase instanciable");\r
+ return null;\r
+ }\r
+ }\r
+ //si la raiz es un objeto\r
+ else{\r
+ if(tipo_raiz.getFirstChild().getNextSibling().getType() != INST){\r
+ System.out.println("ERROR CT: "+raiz.getFirstChild().getText()+" es un objeto de clase no instanciable");\r
+ return null;\r
+ }\r
+ }\r
+ //comprobar que "atrib" sea un atributo o metodo de la clase y ademas sea visible\r
+ aux = tipo_raiz.getFirstChild().getNextSibling().getNextSibling();\r
+ while(aux!= null){\r
+ if(aux.getType() == METODO){\r
+ if(aux.getFirstChild().getFirstChild().equals(atrib))\r
+ break;\r
+ }else{ //atributo\r
+ if(aux.getFirstChild().equals(atrib))\r
+ break;\r
+ }\r
+ aux = aux.getNextSibling();\r
+ }\r
+ if(aux == null){\r
+ System.out.println("ERROR CT: el atributo "+atrib.getText()+" no pertenece a la clase "+raiz.getFirstChild().getText());\r
+ return null;\r
+ }\r
+ if(aux.getFirstChild().getNextSibling().getNextSibling().getType() != VISIBLE){\r
+ System.out.println("ERROR CT: el atributo "+atrib.getText()+" no es visible");\r
+ return null;\r
+ }\r
+ \r
+ //tipo de la expresion\r
+ if(aux.getType() == METODO){\r
+ tipo = aux.getFirstChild();\r
+ result.setLVal(false);\r
+ result.setRVal(false);\r
+ }else{ //atributo\r
+ tipo = aux.getFirstChild().getNextSibling();\r
+ result.setLVal(true);\r
+ result.setRVal(true);\r
+ }\r
+ result.setTipo(tipo);\r
+ return result;\r
+ \r
+ }\r
+ \r
+ //hay que pasarle la raiz para saber el nombre de la raiz cuando no es un metodo\r
+ Atr_Expr AS_Llamada(Atr_Expr atr_raiz, LinkedList expresiones){\r
+ ListIterator it = expresiones.listIterator();\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST pars, par_f, tipo;\r
+ Atr_Expr par_r;\r
+ \r
+ //comprobar que atr_raiz no se a null\r
+ if(atr_raiz == null || expresiones == null){\r
+ return null;\r
+ }\r
+ //comprobar que la raiz sea de tipo prototipo\r
+ if(atr_raiz.getTipo().getType() != PROTOTIPO){\r
+ System.out.println("ERROR CT: "+atr_raiz.getTipo().getText()+" no es un metodo.");\r
+ return null;\r
+ }\r
+ //comprobar que los parametros reales coinciden con los formales\r
+ pars = atr_raiz.getTipo().getFirstChild().getNextSibling();\r
+ par_f = pars.getFirstChild();\r
+ while (it.hasNext() && (par_f != null)){\r
+ par_r = (Atr_Expr)it.next();\r
+ if(! par_f.getFirstChild().getNextSibling().equalsTree(par_r.getTipo())){\r
+ System.out.println("ERROR CT: El numero de parametros en el metodo \""+atr_raiz.getTipo().getFirstChild().getText()+"\" es incorrecto.");\r
+ return null;\r
+ }\r
+ par_f = par_f.getNextSibling();\r
+ }\r
+ if(it.hasNext() && (par_f == null)){\r
+ System.out.println("ERROR CT: El numero de parametros en el metodo \""+atr_raiz.getTipo().getFirstChild().getText()+"\" es incorrecto.");\r
+ return null;\r
+ }\r
+ if(!it.hasNext() && (par_f != null)){\r
+ System.out.println("ERROR CT: El numero de parametros en el metodo \""+atr_raiz.getTipo().getFirstChild().getText()+"\" es incorrecto.");\r
+ return null;\r
+ }\r
+ //el tipo de la expresion es el rango del metodo\r
+ tipo = atr_raiz.getTipo().getFirstChild().getNextSibling().getNextSibling().getFirstChild();\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ result.setTipo(tipo);\r
+ return result;\r
+ }\r
+ \r
+ Atr_Expr AS_Acceso_Tabla(Atr_Expr atr_raiz, LinkedList expresiones){\r
+ if(atr_raiz == null || expresiones == null) return null;\r
+ ListIterator it = expresiones.listIterator();\r
+ Atr_Expr result = new Atr_Expr();\r
+ Atr_Expr aux;\r
+ AST tipo;\r
+ int tam = 0;\r
+ //comprobar que el tipo de la raizes una formacion\r
+ //TODO\r
+ if(atr_raiz.getTipo().getType() != FORMACION){\r
+ System.out.println("ERROR CT: intentando acceder a \""+atr_raiz.getTipo().getText()+"\" como formacion");\r
+ return null;\r
+ }\r
+ //comprobar que el numero de expresiones coincida con el numero de dimensiones\r
+ while(it.hasNext()){\r
+ tam++;\r
+ aux = (Atr_Expr) it.next();\r
+ if(aux == null) return null;\r
+ if(aux.getTipo().getType() != ENTERO){\r
+ System.out.println("ERROR CT: no coinciden el numero de expresiones en el acceso a formacion");\r
+ return null;\r
+ }\r
+ }\r
+ if(tam != atr_raiz.getTipo().getFirstChild().getNumberOfChildren()){\r
+ System.out.println("ERROR CT: no coinciden el numero de expresiones en el acceso a formacion");\r
+ return null;\r
+ }\r
+ tipo = atr_raiz.getTipo().getFirstChild().getNextSibling();\r
+ result.setTipo(tipo);\r
+ result.setLVal(atr_raiz.getLVal());\r
+ result.setRVal(atr_raiz.getRVal());\r
+ return result;\r
+ }\r
+ \r
+ \r
+ \r
+ //AS DE EXPRESIONES\r
+ \r
+ //Expresiones binarias aritmeticas\r
+ Atr_Expr AS_Exp_Bin_Arit(Atr_Expr e1, Atr_Expr e2){\r
+ Atr_Expr result = new Atr_Expr();\r
+ String men="";\r
+ if(e1 == null || e2 == null) return null;\r
+ \r
+ //Comprobamos que e1 y e2 sean consultables\r
+ if(!e1.getLVal() || !e2.getRVal()){\r
+ if (!e2.getRVal()) men="ERROR LR: la expresion no puede aparecer a la derecha de una expresion binaria" ;\r
+ if (!e1.getLVal()) men="ERROR LR: la expresion no puede aparecer a la izquierda de una expresion binaria" ;\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //Comprobamos que e1 y e2 sean numericas y compatibles\r
+ if((e1.getTipo().getType()!=ENTERO) && (e1.getTipo().getType()!=REAL) ||\r
+ (e2.getTipo().getType()!=ENTERO) && (e2.getTipo().getType()!=REAL)){\r
+ System.out.println("ERROR CT: no son expresiones numericas ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")");\r
+ return null;\r
+ }\r
+ if(!e1.getTipo().equals(e2.getTipo())){\r
+ System.out.println("ERROR CT: Los tipos no son compatibles ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")");\r
+ return null;\r
+ }\r
+ \r
+ //Calculamos el tipo\r
+ result.setTipo(e1.getTipo());\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ \r
+ //Expresiones binarias logicas\r
+ Atr_Expr AS_Exp_Bin_Log(Atr_Expr e1, Atr_Expr e2){\r
+ Atr_Expr result = new Atr_Expr();\r
+ String men = "";\r
+ \r
+ if(e1 == null || e2 == null) return null;\r
+ //Comprobar que las expresiones son consultables\r
+ if(!e1.getLVal() || !e2.getRVal()){\r
+ if (!e2.getRVal()) men ="ERROR LR: la expresion no puede aparecer a la derecha de la expresion" ;\r
+ if (!e1.getLVal()) men ="ERROR LR: la expresion "+e1.getTipo().getFirstChild().getText()+" no puede aparecer a la izquierda de la expresion" ;\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //Comprobamos que sean de tipo logico\r
+ if((e1.getTipo().getType()!=LOGICO) || (e2.getTipo().getType()!=LOGICO)){\r
+ if (e1.getTipo().getType()!=LOGICO)\r
+ men = "ERROR CT: la expresion "+e1.getTipo().getFirstChild().getText()+"no es de tipo logico";\r
+ if (e2.getTipo().getType()!=LOGICO)\r
+ men = "ERROR CT: la expresion "+e2.getTipo().getFirstChild().getText()+"no es de tipo logico";\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //Calculamos el tipo\r
+ result.setTipo(e1.getTipo());\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //Expresiones binarias relacionales\r
+ Atr_Expr AS_Exp_Bin_Rel(Atr_Expr e1, Atr_Expr e2, AST operador){\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo;\r
+ String men = "";\r
+ \r
+ if(e1 == null || e2 == null || operador == null) return null;\r
+ //Comprobamos que las expresiones son consultables\r
+ if(!e1.getLVal() || !e2.getRVal()){\r
+ if (!e2.getRVal()) men ="ERROR LR: la expresion no se puede consultar en la expresion binaria" ;\r
+ if (!e1.getLVal()) men ="ERROR LR: la expresion "+e1.getTipo().getFirstChild().getText()+" no puede aparecer a la izquierda en la expresion";\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //No dejamos que se utilicen formaciones y comprobamos la compatibilidad de las expresiones\r
+ if(e1.getTipo().getType()==FORMACION){\r
+ System.out.println("ERROR CT: no puede tener formaciones en expresiones relacionales");\r
+ return null;\r
+ }\r
+ men = "ERROR CT: Los tipos no son compatibles ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")";\r
+ if(!e1.getTipo().equals(e2.getTipo())){\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+\r
+ if((e1.getTipo().getType() == CLASE) && (!e1.getTipo().getFirstChild().equals(e2.getTipo().getFirstChild()))){ //Comparamos las clases por nombre\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //Miramos los grupos de operadores\r
+ if((operador.getType()!=IGUAL && operador.getType()!=DISTINTO) && (e1.getTipo().getType()==CLASE || e1.getTipo().getType()==LOGICO)){\r
+ System.out.println("ERROR CT: el operador \""+operador.getText()+"\" no esta permitido para los tipos usados ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")");\r
+ return null;\r
+ }\r
+ \r
+ //Establecemos el tipo\r
+ tipo = (AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(LOGICO,"logico")));\r
+ result.setTipo(tipo);\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //Expresiones unarias aritmeticas == MENOS UNARIO\r
+ Atr_Expr AS_Exp_Una_Arit(Atr_Expr e){\r
+ Atr_Expr result = new Atr_Expr();\r
+ String men="";\r
+ \r
+ if(e == null) return null;\r
+ //e tiene que ser consultable\r
+ if(!e.getRVal()){\r
+ men ="ERROR LR: la expresion no es consultable" ;\r
+ System.out.println(men);\r
+ return null;\r
+ }\r
+ \r
+ //comprobar que e es de tipo numerico\r
+ if( e.getTipo().getType()!=ENTERO && e.getTipo().getType()!=REAL){\r
+ System.out.println("ERROR CT: el menos unario solo puede ser utilizado en expresiones numericas");\r
+ return null;\r
+ }\r
+ \r
+ //Establecemos el tipo\r
+ result.setTipo(e.getTipo());\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //Expresiones unarias logicas == NEGACION\r
+ //Identica a la anterior\r
+ Atr_Expr AS_Exp_Una_Log(Atr_Expr e){\r
+ Atr_Expr result = new Atr_Expr();\r
+ \r
+ if(e == null) return null;\r
+ //e tiene que ser consultable\r
+ if(!e.getRVal()){\r
+ System.out.println("ERROR LR: la expresion no es consultable" );\r
+ return null;\r
+ }\r
+ \r
+ //comprobar que e es de tipo numerico\r
+ if( e.getTipo().getType()!=LOGICO){\r
+ System.out.println("ERROR CT: la negacion solo se puede utilizar con expresiones logicas");\r
+ return null;\r
+ }\r
+ \r
+ //Establecemos el tipo\r
+ result.setTipo(e.getTipo());\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //Instrucciones\r
+ //Asignacion\r
+ void AS_Asignacion(Atr_Expr e1, Atr_Expr e2, AST e3, AST e4){\r
+ //comprobar si alguno es null\r
+ String men = "";\r
+ if(e1==null || e2 == null) return;\r
+ \r
+ //Comprobamos la consultabilidad de las expresiones\r
+ if(!e1.getLVal() || !e2.getRVal()){\r
+ if (!e2.getRVal())\r
+ men ="ERROR LR: la expresion "+e4.getFirstChild().getText()+" no puede aparecer a la derecha de una asignacion." ;\r
+ if (!e1.getLVal()) men ="ERROR LR: el "+e3.getFirstChild().getNextSibling().getText()+" "+e3.getFirstChild().getText()+" no puede aparecer a la izquierda de una asignacion." ;\r
+ System.out.println(men);\r
+ return;\r
+ }\r
+ \r
+ //No dejamos asignar formaciones y comprobamos la compatibilidad de tipos\r
+ if(e1.getTipo().getType()==FORMACION){\r
+ System.out.println("ERROR CT: no dejamos asignar formaciones");\r
+ }\r
+ men = "ERROR CT: Los tipos no son compatibles ("+e1.getTipo().getText()+" y "+e2.getTipo().getText()+")";\r
+ if(!e1.getTipo().equals(e2.getTipo())){\r
+ System.out.println(men);\r
+ }\r
+ if((e1.getTipo().getType() == CLASE) && (!e1.getTipo().getFirstChild().equals(e2.getTipo().getFirstChild()))){ //Comparamos las clases por nombre\r
+ System.out.println(men);\r
+ }\r
+ }\r
+ \r
+ //Condiciones\r
+ void AS_Condicional(Atr_Expr e){\r
+ String men = "";\r
+ if (e == null) return;\r
+ if(!e.getRVal()){\r
+ men ="ERROR LR: la expresion no es consultable" ;\r
+ System.out.println(men);\r
+ return;\r
+ }\r
+ \r
+ //Comprobamos que es de tipo logico\r
+ if(e.getTipo().getType()!=LOGICO){\r
+ System.out.println("ERROR CT: no es un tipo logico");\r
+ }\r
+ }\r
+ \r
+ //Instruccion de devolucion\r
+ int AS_Devolucion(AST tipo_dev, Atr_Expr e, int cont){\r
+ String men = "";\r
+// String men = "ERROR CT: Los tipos no son compatibles (entero y real)"\r
+ if(tipo_dev == null || e == null) return cont+1;\r
+ //Comprobamos que el metodo sea funcional\r
+\r
+ if(cont == -1){\r
+ System.out.println("ERROR CT: el metodo no es funcional");\r
+ return -1;\r
+ }\r
+\r
+ //Comprobar que la expresion e es consultable\r
+ if(!e.getRVal()){\r
+ System.out.println("ERROR CT: la expresion no es consultable, no se puede devolver");\r
+ }\r
+ \r
+ men = "ERROR CT: Los tipos no son compatibles ("+e.getTipo().getText()+" y "+tipo_dev.getText()+")";\r
+ //Comprobamos que el tipo de la expresion es compatible con el tipo que se devuelve\r
+ if(!e.getTipo().equals(tipo_dev)){\r
+ System.out.println(men);\r
+ }\r
+ if(tipo_dev.getType()==CLASE && (!tipo_dev.getFirstChild().equals(e.getTipo().getFirstChild()))){\r
+ System.out.println(men);\r
+ }\r
+ \r
+ if(tipo_dev.getType()==FORMACION && (!tipo_dev.equals(e.getTipo()))){\r
+ System.out.println(men);\r
+ }\r
+ \r
+ return cont + 1;\r
+ }\r
+ \r
+ \r
+ Atr_Expr AS_Crear(Atr_Expr as, AST clase){\r
+ if (as == null || clase == null){\r
+ System.out.println("ERROR CT: no se puede crear");\r
+ return null;\r
+ }\r
+ //comprobar que el tipo de la variable es el mismo que el del interior de crear\r
+ Atr_Expr result = new Atr_Expr();\r
+ AST tipo = as.getTipo();\r
+ if(tipo.getType() != CLASE){\r
+ System.out.println("ERROR CT: no es una clase");\r
+ return null;\r
+ }\r
+ if(!(tipo.getFirstChild().getNextSibling().getType() == INST)){\r
+ System.out.println("ERROR CT: la clase no es instanciable");\r
+ return null;\r
+ }\r
+ AST tipo_var = tipo.getFirstChild();\r
+ AST interior = clase;\r
+ if(!tipo_var.getText().equals(interior.getText())){\r
+ if(interior.getType() == ACCESO_SIMPLE)\r
+ System.out.println("ERROR CT: Los tipos no son compatibles ("+tipo_var.getText()+" y "+interior.getFirstChild().getText()+")");\r
+ else\r
+ System.out.println("ERROR CT: Los tipos no son compatibles ("+tipo_var.getText()+" y "+interior.getText()+")");\r
+ return null;\r
+ }\r
+\r
+ result.setLVal(false);\r
+ result.setRVal(false);\r
+ //el tipo es el de la variable\r
+ result.setTipo(tipo);\r
+ \r
+ return result;\r
+ } \r
+ \r
+ //AS Escribir\r
+ void AS_Escribir(Atr_Expr e, AST exp){\r
+ if (e == null){\r
+ if(exp.getType() == ACCESO_SIMPLE)\r
+ System.out.println("ERROR CT: no se puede escribir "+ exp.getFirstChild().getText());\r
+ else\r
+ System.out.println("ERROR CT: no se puede escribir "+ exp.getText());\r
+ return;\r
+ }\r
+ //Comprobamos que la expresion se pueda consultar\r
+ if(!e.getRVal()){\r
+ System.out.println("ERROR CT: la expresion no es consultable, no se puede escribir");\r
+ }\r
+ }\r
+\r
+ \r
+ //AS Entero A Real\r
+ Atr_Expr AS_Entero_A_Real(Atr_Expr e1){\r
+ Atr_Expr result = new Atr_Expr();\r
+ if (e1 == null) return null;\r
+ AST tipo = e1.getTipo();\r
+ if(tipo.getType() != ENTERO){\r
+ System.out.println("ERROR CT: El tipo del parametro del operador enteroareal es incorrecto.");\r
+ return null;\r
+ }\r
+ result.setTipo((AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(REAL,"real"))));\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ return result;\r
+ }\r
+ Atr_Expr AS_Real_A_Entero(Atr_Expr e1){\r
+ Atr_Expr result = new Atr_Expr();\r
+ \r
+ if (e1 == null) return null;\r
+ AST tipo = e1.getTipo();\r
+ if(tipo.getType() != REAL){\r
+ System.out.println("ERROR CT: El tipo del parametro del operador realaentero es incorrecto.");\r
+ return null;\r
+ }\r
+ result.setTipo((AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(ENTERO,"entero"))));\r
+ result.setLVal(false);\r
+ result.setRVal(true);\r
+ return result;\r
+ }\r
+ \r
+ \r
+public AnaSem2() {
+ tokenNames = _tokenNames;
+}
+
+ public final void declaracion_modulo(AST _t) throws RecognitionException {
+
+ AST declaracion_modulo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_modulo_AST = null;
+
+ try { // for error handling
+ AST __t13839 = _t;
+ AST tmp1_AST = null;
+ AST tmp1_AST_in = null;
+ tmp1_AST = astFactory.create((AST)_t);
+ tmp1_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp1_AST);
+ ASTPair __currentAST13839 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MODULO);
+ _t = _t.getFirstChild();
+ nombre_modulo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ definicion_modulo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13839;
+ _t = __t13839;
+ _t = _t.getNextSibling();
+ declaracion_modulo_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_modulo_AST;
+ _retTree = _t;
+ }
+
+ public final void nombre_modulo(AST _t) throws RecognitionException {
+
+ AST nombre_modulo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST nombre_modulo_AST = null;
+
+ try { // for error handling
+ AST tmp2_AST = null;
+ AST tmp2_AST_in = null;
+ tmp2_AST = astFactory.create((AST)_t);
+ tmp2_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp2_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ nombre_modulo_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = nombre_modulo_AST;
+ _retTree = _t;
+ }
+
+ public final void definicion_modulo(AST _t) throws RecognitionException {
+
+ AST definicion_modulo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST definicion_modulo_AST = null;
+
+ try { // for error handling
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case IMPORTACION:
+ {
+ importacion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ break;
+ }
+ case EXPORTACION:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ {
+ int _cnt13844=0;
+ _loop13844:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==EXPORTACION)) {
+ exportacion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ }
+ else {
+ if ( _cnt13844>=1 ) { break _loop13844; } else {throw new NoViableAltException(_t);}
+ }
+
+ _cnt13844++;
+ } while (true);
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case IMPLEMENTACION:
+ {
+ implementacion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ definicion_modulo_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = definicion_modulo_AST;
+ _retTree = _t;
+ }
+
+ public final void importacion(AST _t) throws RecognitionException {
+
+ AST importacion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST importacion_AST = null;
+
+ try { // for error handling
+ AST __t13847 = _t;
+ AST tmp3_AST = null;
+ AST tmp3_AST_in = null;
+ tmp3_AST = astFactory.create((AST)_t);
+ tmp3_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp3_AST);
+ ASTPair __currentAST13847 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,IMPORTACION);
+ _t = _t.getFirstChild();
+ lista_ident(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13847;
+ _t = __t13847;
+ _t = _t.getNextSibling();
+ importacion_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = importacion_AST;
+ _retTree = _t;
+ }
+
+ public final void exportacion(AST _t) throws RecognitionException {
+
+ AST exportacion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST exportacion_AST = null;
+
+ try { // for error handling
+ AST __t13852 = _t;
+ AST tmp4_AST = null;
+ AST tmp4_AST_in = null;
+ tmp4_AST = astFactory.create((AST)_t);
+ tmp4_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp4_AST);
+ ASTPair __currentAST13852 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,EXPORTACION);
+ _t = _t.getFirstChild();
+ lista_declaraciones_clases(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13852;
+ _t = __t13852;
+ _t = _t.getNextSibling();
+ exportacion_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = exportacion_AST;
+ _retTree = _t;
+ }
+
+ public final void implementacion(AST _t) throws RecognitionException {
+
+ AST implementacion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST implementacion_AST = null;
+
+ try { // for error handling
+ AST __t13854 = _t;
+ AST tmp5_AST = null;
+ AST tmp5_AST_in = null;
+ tmp5_AST = astFactory.create((AST)_t);
+ tmp5_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp5_AST);
+ ASTPair __currentAST13854 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,IMPLEMENTACION);
+ _t = _t.getFirstChild();
+ lista_declaraciones_clases(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13854;
+ _t = __t13854;
+ _t = _t.getNextSibling();
+ implementacion_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = implementacion_AST;
+ _retTree = _t;
+ }
+
+ public final void lista_ident(AST _t) throws RecognitionException {
+
+ AST lista_ident_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST lista_ident_AST = null;
+
+ try { // for error handling
+ {
+ int _cnt13850=0;
+ _loop13850:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==IDENT)) {
+ AST tmp6_AST = null;
+ AST tmp6_AST_in = null;
+ tmp6_AST = astFactory.create((AST)_t);
+ tmp6_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp6_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ }
+ else {
+ if ( _cnt13850>=1 ) { break _loop13850; } else {throw new NoViableAltException(_t);}
+ }
+
+ _cnt13850++;
+ } while (true);
+ }
+ lista_ident_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = lista_ident_AST;
+ _retTree = _t;
+ }
+
+ public final void lista_declaraciones_clases(AST _t) throws RecognitionException {
+
+ AST lista_declaraciones_clases_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST lista_declaraciones_clases_AST = null;
+
+ try { // for error handling
+ {
+ _loop13857:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==CLASE)) {
+ declaracion_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ }
+ else {
+ break _loop13857;
+ }
+
+ } while (true);
+ }
+ lista_declaraciones_clases_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = lista_declaraciones_clases_AST;
+ _retTree = _t;
+ }
+
+ public final void declaracion_clase(AST _t) throws RecognitionException {
+
+ AST declaracion_clase_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_clase_AST = null;
+
+ try { // for error handling
+ AST __t13859 = _t;
+ AST tmp7_AST = null;
+ AST tmp7_AST_in = null;
+ tmp7_AST = astFactory.create((AST)_t);
+ tmp7_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp7_AST);
+ ASTPair __currentAST13859 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,CLASE);
+ _t = _t.getFirstChild();
+ nombre_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ cualificador_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ definicion_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13859;
+ _t = __t13859;
+ _t = _t.getNextSibling();
+ declaracion_clase_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_clase_AST;
+ _retTree = _t;
+ }
+
+ public final void nombre_clase(AST _t) throws RecognitionException {
+
+ AST nombre_clase_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST nombre_clase_AST = null;
+
+ try { // for error handling
+ AST tmp8_AST = null;
+ AST tmp8_AST_in = null;
+ tmp8_AST = astFactory.create((AST)_t);
+ tmp8_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp8_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ nombre_clase_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = nombre_clase_AST;
+ _retTree = _t;
+ }
+
+ public final void cualificador_clase(AST _t) throws RecognitionException {
+
+ AST cualificador_clase_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST cualificador_clase_AST = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case INST:
+ {
+ AST tmp9_AST = null;
+ AST tmp9_AST_in = null;
+ tmp9_AST = astFactory.create((AST)_t);
+ tmp9_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp9_AST);
+ match(_t,INST);
+ _t = _t.getNextSibling();
+ cualificador_clase_AST = (AST)currentAST.root;
+ break;
+ }
+ case NO_INST:
+ {
+ AST tmp10_AST = null;
+ AST tmp10_AST_in = null;
+ tmp10_AST = astFactory.create((AST)_t);
+ tmp10_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp10_AST);
+ match(_t,NO_INST);
+ _t = _t.getNextSibling();
+ cualificador_clase_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = cualificador_clase_AST;
+ _retTree = _t;
+ }
+
+ public final void definicion_clase(AST _t) throws RecognitionException {
+
+ AST definicion_clase_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST definicion_clase_AST = null;
+
+ try { // for error handling
+ declaraciones_elementos_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ definicion_clase_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = definicion_clase_AST;
+ _retTree = _t;
+ }
+
+ public final void declaraciones_elementos_clase(AST _t) throws RecognitionException {
+
+ AST declaraciones_elementos_clase_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaraciones_elementos_clase_AST = null;
+
+ try { // for error handling
+ {
+ _loop13865:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==ATRIBUTO||_t.getType()==METODO)) {
+ declaracion_elemento_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ }
+ else {
+ break _loop13865;
+ }
+
+ } while (true);
+ }
+ declaraciones_elementos_clase_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaraciones_elementos_clase_AST;
+ _retTree = _t;
+ }
+
+ public final void declaracion_elemento_clase(AST _t) throws RecognitionException {
+
+ AST declaracion_elemento_clase_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_elemento_clase_AST = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case METODO:
+ {
+ AST __t13867 = _t;
+ AST tmp11_AST = null;
+ AST tmp11_AST_in = null;
+ tmp11_AST = astFactory.create((AST)_t);
+ tmp11_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp11_AST);
+ ASTPair __currentAST13867 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,METODO);
+ _t = _t.getFirstChild();
+ declaracion_metodo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ cualificador_elemento_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13867;
+ _t = __t13867;
+ _t = _t.getNextSibling();
+ declaracion_elemento_clase_AST = (AST)currentAST.root;
+ break;
+ }
+ case ATRIBUTO:
+ {
+ AST __t13868 = _t;
+ AST tmp12_AST = null;
+ AST tmp12_AST_in = null;
+ tmp12_AST = astFactory.create((AST)_t);
+ tmp12_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp12_AST);
+ ASTPair __currentAST13868 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,ATRIBUTO);
+ _t = _t.getFirstChild();
+ AST tmp13_AST = null;
+ AST tmp13_AST_in = null;
+ tmp13_AST = astFactory.create((AST)_t);
+ tmp13_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp13_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ tipo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ cualificador_elemento_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13868;
+ _t = __t13868;
+ _t = _t.getNextSibling();
+ declaracion_elemento_clase_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_elemento_clase_AST;
+ _retTree = _t;
+ }
+
+ public final void declaracion_metodo(AST _t) throws RecognitionException {
+
+ AST declaracion_metodo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_metodo_AST = null;
+ AST tipodev;
+
+ try { // for error handling
+ tipodev=prototipo_metodo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ definicion_metodo(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ if (cont_dev == 0){
+ System.out.println("ERROR: Metodo funcional que no devuelve nada");
+ System.exit(-1);
+ }
+
+ declaracion_metodo_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_metodo_AST;
+ _retTree = _t;
+ }
+
+ public final void cualificador_elemento_clase(AST _t) throws RecognitionException {
+
+ AST cualificador_elemento_clase_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST cualificador_elemento_clase_AST = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case OCULTO:
+ {
+ AST tmp14_AST = null;
+ AST tmp14_AST_in = null;
+ tmp14_AST = astFactory.create((AST)_t);
+ tmp14_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp14_AST);
+ match(_t,OCULTO);
+ _t = _t.getNextSibling();
+ cualificador_elemento_clase_AST = (AST)currentAST.root;
+ break;
+ }
+ case VISIBLE:
+ {
+ AST tmp15_AST = null;
+ AST tmp15_AST_in = null;
+ tmp15_AST = astFactory.create((AST)_t);
+ tmp15_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp15_AST);
+ match(_t,VISIBLE);
+ _t = _t.getNextSibling();
+ cualificador_elemento_clase_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = cualificador_elemento_clase_AST;
+ _retTree = _t;
+ }
+
+ public final void tipo(AST _t) throws RecognitionException {
+
+ AST tipo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST tipo_AST = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ENTERO:
+ case REAL:
+ case LOGICO:
+ case CARACTER:
+ {
+ tipo_predefinido_simple(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ tipo_AST = (AST)currentAST.root;
+ break;
+ }
+ case FORMACION:
+ {
+ tipo_predefinido_compuesto(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ tipo_AST = (AST)currentAST.root;
+ break;
+ }
+ case IDENT:
+ {
+ AST tmp16_AST = null;
+ AST tmp16_AST_in = null;
+ tmp16_AST = astFactory.create((AST)_t);
+ tmp16_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp16_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ tipo_AST = (AST)currentAST.root;
+ break;
+ }
+ case ERROR:
+ {
+ declaracion_error(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ tipo_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = tipo_AST;
+ _retTree = _t;
+ }
+
+ public final AST prototipo_metodo(AST _t) throws RecognitionException {
+ AST tipodev=null;
+
+ AST prototipo_metodo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST prototipo_metodo_AST = null;
+ AST t_AST = null;
+ AST t = null;
+ AST v = null;
+ AST v_AST = null;
+
+ try { // for error handling
+ AST __t13872 = _t;
+ AST tmp17_AST = null;
+ AST tmp17_AST_in = null;
+ tmp17_AST = astFactory.create((AST)_t);
+ tmp17_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp17_AST);
+ ASTPair __currentAST13872 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,PROTOTIPO);
+ _t = _t.getFirstChild();
+ AST tmp18_AST = null;
+ AST tmp18_AST_in = null;
+ tmp18_AST = astFactory.create((AST)_t);
+ tmp18_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp18_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ AST __t13873 = _t;
+ AST tmp19_AST = null;
+ AST tmp19_AST_in = null;
+ tmp19_AST = astFactory.create((AST)_t);
+ tmp19_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp19_AST);
+ ASTPair __currentAST13873 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,PARAMETROS);
+ _t = _t.getFirstChild();
+ declaracion_parametros(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13873;
+ _t = __t13873;
+ _t = _t.getNextSibling();
+ AST __t13874 = _t;
+ AST tmp20_AST = null;
+ AST tmp20_AST_in = null;
+ tmp20_AST = astFactory.create((AST)_t);
+ tmp20_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp20_AST);
+ ASTPair __currentAST13874 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,RESULTADO);
+ _t = _t.getFirstChild();
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ERROR:
+ case IDENT:
+ case ENTERO:
+ case REAL:
+ case LOGICO:
+ case CARACTER:
+ case FORMACION:
+ {
+ t = _t==ASTNULL ? null : (AST)_t;
+ tipo(_t);
+ _t = _retTree;
+ t_AST = (AST)returnAST;
+ astFactory.addASTChild(currentAST, returnAST);
+ cont_dev = 0; // inicializa el contador de instrucciones DEV
+ tipodev = t;
+ break;
+ }
+ case VACIO:
+ {
+ v = (AST)_t;
+ AST v_AST_in = null;
+ v_AST = astFactory.create(v);
+ astFactory.addASTChild(currentAST, v_AST);
+ match(_t,VACIO);
+ _t = _t.getNextSibling();
+ cont_dev = -1; // marca a -1 para indicar que es un procedimiento
+ tipodev = v;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ currentAST = __currentAST13874;
+ _t = __t13874;
+ _t = _t.getNextSibling();
+ currentAST = __currentAST13872;
+ _t = __t13872;
+ _t = _t.getNextSibling();
+ prototipo_metodo_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = prototipo_metodo_AST;
+ _retTree = _t;
+ return tipodev;
+ }
+
+ public final void definicion_metodo(AST _t,
+ AST tipodev
+ ) throws RecognitionException {
+
+ AST definicion_metodo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST definicion_metodo_AST = null;
+
+ try { // for error handling
+ AST __t13882 = _t;
+ AST tmp21_AST = null;
+ AST tmp21_AST_in = null;
+ tmp21_AST = astFactory.create((AST)_t);
+ tmp21_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp21_AST);
+ ASTPair __currentAST13882 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,DEFINICION);
+ _t = _t.getFirstChild();
+ AST __t13883 = _t;
+ AST tmp22_AST = null;
+ AST tmp22_AST_in = null;
+ tmp22_AST = astFactory.create((AST)_t);
+ tmp22_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp22_AST);
+ ASTPair __currentAST13883 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,VARIABLES_LOCALES);
+ _t = _t.getFirstChild();
+ declaracion_variables_locales(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13883;
+ _t = __t13883;
+ _t = _t.getNextSibling();
+ AST __t13884 = _t;
+ AST tmp23_AST = null;
+ AST tmp23_AST_in = null;
+ tmp23_AST = astFactory.create((AST)_t);
+ tmp23_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp23_AST);
+ ASTPair __currentAST13884 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,INSTRUCCIONES);
+ _t = _t.getFirstChild();
+ instrucciones(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13884;
+ _t = __t13884;
+ _t = _t.getNextSibling();
+ currentAST = __currentAST13882;
+ _t = __t13882;
+ _t = _t.getNextSibling();
+ definicion_metodo_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = definicion_metodo_AST;
+ _retTree = _t;
+ }
+
+ public final void declaracion_parametros(AST _t) throws RecognitionException {
+
+ AST declaracion_parametros_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_parametros_AST = null;
+
+ try { // for error handling
+ {
+ _loop13878:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==PARAMETRO)) {
+ declaracion_parametro(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ }
+ else {
+ break _loop13878;
+ }
+
+ } while (true);
+ }
+ declaracion_parametros_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_parametros_AST;
+ _retTree = _t;
+ }
+
+ public final void declaracion_parametro(AST _t) throws RecognitionException {
+
+ AST declaracion_parametro_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_parametro_AST = null;
+
+ try { // for error handling
+ AST __t13880 = _t;
+ AST tmp24_AST = null;
+ AST tmp24_AST_in = null;
+ tmp24_AST = astFactory.create((AST)_t);
+ tmp24_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp24_AST);
+ ASTPair __currentAST13880 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,PARAMETRO);
+ _t = _t.getFirstChild();
+ AST tmp25_AST = null;
+ AST tmp25_AST_in = null;
+ tmp25_AST = astFactory.create((AST)_t);
+ tmp25_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp25_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ tipo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13880;
+ _t = __t13880;
+ _t = _t.getNextSibling();
+ declaracion_parametro_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_parametro_AST;
+ _retTree = _t;
+ }
+
+ public final void declaracion_variables_locales(AST _t) throws RecognitionException {
+
+ AST declaracion_variables_locales_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_variables_locales_AST = null;
+
+ try { // for error handling
+ {
+ _loop13887:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==VARIABLE_LOCAL)) {
+ declaracion_variable_local(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ }
+ else {
+ break _loop13887;
+ }
+
+ } while (true);
+ }
+ declaracion_variables_locales_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_variables_locales_AST;
+ _retTree = _t;
+ }
+
+ public final void instrucciones(AST _t,
+ AST tipodev
+ ) throws RecognitionException {
+
+ AST instrucciones_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST instrucciones_AST = null;
+
+ try { // for error handling
+ {
+ _loop13893:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==INSTRUCCION)) {
+ instruccion(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ }
+ else {
+ break _loop13893;
+ }
+
+ } while (true);
+ }
+ instrucciones_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = instrucciones_AST;
+ _retTree = _t;
+ }
+
+ public final void declaracion_variable_local(AST _t) throws RecognitionException {
+
+ AST declaracion_variable_local_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_variable_local_AST = null;
+
+ try { // for error handling
+ AST __t13889 = _t;
+ AST tmp26_AST = null;
+ AST tmp26_AST_in = null;
+ tmp26_AST = astFactory.create((AST)_t);
+ tmp26_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp26_AST);
+ ASTPair __currentAST13889 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,VARIABLE_LOCAL);
+ _t = _t.getFirstChild();
+ AST tmp27_AST = null;
+ AST tmp27_AST_in = null;
+ tmp27_AST = astFactory.create((AST)_t);
+ tmp27_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp27_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ tipo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13889;
+ _t = __t13889;
+ _t = _t.getNextSibling();
+ declaracion_variable_local_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_variable_local_AST;
+ _retTree = _t;
+ }
+
+ public final void declaracion_error(AST _t) throws RecognitionException {
+
+ AST declaracion_error_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_error_AST = null;
+
+ try { // for error handling
+ AST tmp28_AST = null;
+ AST tmp28_AST_in = null;
+ tmp28_AST = astFactory.create((AST)_t);
+ tmp28_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp28_AST);
+ match(_t,ERROR);
+ _t = _t.getNextSibling();
+ declaracion_error_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_error_AST;
+ _retTree = _t;
+ }
+
+ public final void instruccion(AST _t,
+ AST tipodev
+ ) throws RecognitionException {
+
+ AST instruccion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST instruccion_AST = null;
+
+ try { // for error handling
+ AST __t13895 = _t;
+ AST tmp29_AST = null;
+ AST tmp29_AST_in = null;
+ tmp29_AST = astFactory.create((AST)_t);
+ tmp29_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp29_AST);
+ ASTPair __currentAST13895 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,INSTRUCCION);
+ _t = _t.getFirstChild();
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case LLAMADA:
+ case DEV:
+ case ASIGNACION:
+ case CREAR:
+ case ESCRIBIR:
+ {
+ instruccion_simple(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ break;
+ }
+ case SI:
+ case MIENTRAS:
+ {
+ instruccion_compuesta(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ currentAST = __currentAST13895;
+ _t = __t13895;
+ _t = _t.getNextSibling();
+ instruccion_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = instruccion_AST;
+ _retTree = _t;
+ }
+
+ public final void instruccion_simple(AST _t,
+ AST tipodev
+ ) throws RecognitionException {
+
+ AST instruccion_simple_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST instruccion_simple_AST = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case CREAR:
+ {
+ crear(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ instruccion_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ case LLAMADA:
+ {
+ llamada_metodo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ instruccion_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ case ESCRIBIR:
+ {
+ escribir(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ instruccion_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ case ASIGNACION:
+ {
+ asignacion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ instruccion_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ case DEV:
+ {
+ retorno(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ instruccion_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = instruccion_simple_AST;
+ _retTree = _t;
+ }
+
+ public final void instruccion_compuesta(AST _t,
+ AST tipodev
+ ) throws RecognitionException {
+
+ AST instruccion_compuesta_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST instruccion_compuesta_AST = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case SI:
+ {
+ condicion(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ instruccion_compuesta_AST = (AST)currentAST.root;
+ break;
+ }
+ case MIENTRAS:
+ {
+ iteracion(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ instruccion_compuesta_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = instruccion_compuesta_AST;
+ _retTree = _t;
+ }
+
+ public final void crear(AST _t) throws RecognitionException {
+
+ AST crear_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST crear_AST = null;
+ AST e2_AST = null;
+ AST e2 = null;
+ Atr_Expr e1;
+
+ try { // for error handling
+ AST __t13899 = _t;
+ AST tmp30_AST = null;
+ AST tmp30_AST_in = null;
+ tmp30_AST = astFactory.create((AST)_t);
+ tmp30_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp30_AST);
+ ASTPair __currentAST13899 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,CREAR);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2 = _t==ASTNULL ? null : (AST)_t;
+ expresion(_t);
+ _t = _retTree;
+ e2_AST = (AST)returnAST;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13899;
+ _t = __t13899;
+ _t = _t.getNextSibling();
+ AS_Crear(e1,e2_AST);
+ crear_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = crear_AST;
+ _retTree = _t;
+ }
+
+ public final void llamada_metodo(AST _t) throws RecognitionException {
+
+ AST llamada_metodo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST llamada_metodo_AST = null;
+ Atr_Expr a, res; LinkedList l;
+
+ try { // for error handling
+ AST __t13908 = _t;
+ AST tmp31_AST = null;
+ AST tmp31_AST_in = null;
+ tmp31_AST = astFactory.create((AST)_t);
+ tmp31_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp31_AST);
+ ASTPair __currentAST13908 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,LLAMADA);
+ _t = _t.getFirstChild();
+ a=acceso(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ AST __t13909 = _t;
+ AST tmp32_AST = null;
+ AST tmp32_AST_in = null;
+ tmp32_AST = astFactory.create((AST)_t);
+ tmp32_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp32_AST);
+ ASTPair __currentAST13909 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,EXPRESIONES);
+ _t = _t.getFirstChild();
+ l=lista_expresiones(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13909;
+ _t = __t13909;
+ _t = _t.getNextSibling();
+ currentAST = __currentAST13908;
+ _t = __t13908;
+ _t = _t.getNextSibling();
+ res=AS_Llamada(a,l);
+ if (res != null && res.getTipo().getType() != VACIO){
+ System.out.println("ERROR: Llamada a funcion sin asignar valor devuelto.");
+ System.exit(1);
+ }
+
+ llamada_metodo_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = llamada_metodo_AST;
+ _retTree = _t;
+ }
+
+ public final void escribir(AST _t) throws RecognitionException {
+
+ AST escribir_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST escribir_AST = null;
+ AST e_AST = null;
+ AST e = null;
+ Atr_Expr e1;
+
+ try { // for error handling
+ AST __t13901 = _t;
+ AST tmp33_AST = null;
+ AST tmp33_AST_in = null;
+ tmp33_AST = astFactory.create((AST)_t);
+ tmp33_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp33_AST);
+ ASTPair __currentAST13901 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,ESCRIBIR);
+ _t = _t.getFirstChild();
+ e = _t==ASTNULL ? null : (AST)_t;
+ e1=expresion(_t);
+ _t = _retTree;
+ e_AST = (AST)returnAST;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13901;
+ _t = __t13901;
+ _t = _t.getNextSibling();
+ AS_Escribir(e1, e_AST);
+ escribir_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = escribir_AST;
+ _retTree = _t;
+ }
+
+ public final void asignacion(AST _t) throws RecognitionException {
+
+ AST asignacion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST asignacion_AST = null;
+ AST e3_AST = null;
+ AST e3 = null;
+ AST e4_AST = null;
+ AST e4 = null;
+ Atr_Expr e1, e2;
+
+ try { // for error handling
+ AST __t13904 = _t;
+ AST tmp34_AST = null;
+ AST tmp34_AST_in = null;
+ tmp34_AST = astFactory.create((AST)_t);
+ tmp34_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp34_AST);
+ ASTPair __currentAST13904 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,ASIGNACION);
+ _t = _t.getFirstChild();
+ e3 = _t==ASTNULL ? null : (AST)_t;
+ e1=expresion(_t);
+ _t = _retTree;
+ e3_AST = (AST)returnAST;
+ astFactory.addASTChild(currentAST, returnAST);
+ e4 = _t==ASTNULL ? null : (AST)_t;
+ e2=expresion(_t);
+ _t = _retTree;
+ e4_AST = (AST)returnAST;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13904;
+ _t = __t13904;
+ _t = _t.getNextSibling();
+ AS_Asignacion(e1,e2,e3_AST,e4_AST);
+
+ asignacion_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = asignacion_AST;
+ _retTree = _t;
+ }
+
+ public final void retorno(AST _t,
+ AST tipodev
+ ) throws RecognitionException {
+
+ AST retorno_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST retorno_AST = null;
+ Atr_Expr e;
+
+ try { // for error handling
+ AST __t13906 = _t;
+ AST tmp35_AST = null;
+ AST tmp35_AST_in = null;
+ tmp35_AST = astFactory.create((AST)_t);
+ tmp35_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp35_AST);
+ ASTPair __currentAST13906 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,DEV);
+ _t = _t.getFirstChild();
+ e=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13906;
+ _t = __t13906;
+ _t = _t.getNextSibling();
+ /*AS_Devolucion(tipodev, e);
+ cont_dev++;*/
+ cont_dev=AS_Devolucion(tipodev,e,cont_dev);
+
+ retorno_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = retorno_AST;
+ _retTree = _t;
+ }
+
+ public final Atr_Expr expresion(AST _t) throws RecognitionException {
+ Atr_Expr res=null;
+
+ AST expresion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST expresion_AST = null;
+ AST op1 = null;
+ AST op1_AST = null;
+ AST op2 = null;
+ AST op2_AST = null;
+ AST op3 = null;
+ AST op3_AST = null;
+ AST op4 = null;
+ AST op4_AST = null;
+ AST op5 = null;
+ AST op5_AST = null;
+ AST op6 = null;
+ AST op6_AST = null;
+ AST i = null;
+ AST i_AST = null;
+ AST j = null;
+ AST j_AST = null;
+ AST k = null;
+ AST k_AST = null;
+ AST m = null;
+ AST m_AST = null;
+ AST n = null;
+ AST n_AST = null;
+ Atr_Expr e1,e2; LinkedList l;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case O:
+ {
+ AST __t13922 = _t;
+ AST tmp36_AST = null;
+ AST tmp36_AST_in = null;
+ tmp36_AST = astFactory.create((AST)_t);
+ tmp36_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp36_AST);
+ ASTPair __currentAST13922 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,O);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13922;
+ _t = __t13922;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Log( e1, e2);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case Y:
+ {
+ AST __t13923 = _t;
+ AST tmp37_AST = null;
+ AST tmp37_AST_in = null;
+ tmp37_AST = astFactory.create((AST)_t);
+ tmp37_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp37_AST);
+ ASTPair __currentAST13923 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,Y);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13923;
+ _t = __t13923;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Log( e1, e2);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case NO:
+ {
+ AST __t13924 = _t;
+ AST tmp38_AST = null;
+ AST tmp38_AST_in = null;
+ tmp38_AST = astFactory.create((AST)_t);
+ tmp38_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp38_AST);
+ ASTPair __currentAST13924 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,NO);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13924;
+ _t = __t13924;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Una_Log( e1);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case MAYOR:
+ {
+ AST __t13925 = _t;
+ op1 = _t==ASTNULL ? null :(AST)_t;
+ AST op1_AST_in = null;
+ op1_AST = astFactory.create(op1);
+ astFactory.addASTChild(currentAST, op1_AST);
+ ASTPair __currentAST13925 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MAYOR);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13925;
+ _t = __t13925;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Rel( e1, e2, op1);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case MAYOR_IGUAL:
+ {
+ AST __t13926 = _t;
+ op2 = _t==ASTNULL ? null :(AST)_t;
+ AST op2_AST_in = null;
+ op2_AST = astFactory.create(op2);
+ astFactory.addASTChild(currentAST, op2_AST);
+ ASTPair __currentAST13926 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MAYOR_IGUAL);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13926;
+ _t = __t13926;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Rel( e1, e2, op2);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case MENOR:
+ {
+ AST __t13927 = _t;
+ op3 = _t==ASTNULL ? null :(AST)_t;
+ AST op3_AST_in = null;
+ op3_AST = astFactory.create(op3);
+ astFactory.addASTChild(currentAST, op3_AST);
+ ASTPair __currentAST13927 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MENOR);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13927;
+ _t = __t13927;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Rel( e1, e2, op3);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case MENOR_IGUAL:
+ {
+ AST __t13928 = _t;
+ op4 = _t==ASTNULL ? null :(AST)_t;
+ AST op4_AST_in = null;
+ op4_AST = astFactory.create(op4);
+ astFactory.addASTChild(currentAST, op4_AST);
+ ASTPair __currentAST13928 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MENOR_IGUAL);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13928;
+ _t = __t13928;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Rel( e1, e2, op4);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case IGUAL:
+ {
+ AST __t13929 = _t;
+ op5 = _t==ASTNULL ? null :(AST)_t;
+ AST op5_AST_in = null;
+ op5_AST = astFactory.create(op5);
+ astFactory.addASTChild(currentAST, op5_AST);
+ ASTPair __currentAST13929 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,IGUAL);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13929;
+ _t = __t13929;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Rel( e1, e2, op5);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case DISTINTO:
+ {
+ AST __t13930 = _t;
+ op6 = _t==ASTNULL ? null :(AST)_t;
+ AST op6_AST_in = null;
+ op6_AST = astFactory.create(op6);
+ astFactory.addASTChild(currentAST, op6_AST);
+ ASTPair __currentAST13930 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,DISTINTO);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13930;
+ _t = __t13930;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Rel( e1, e2, op6);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case MAS:
+ {
+ AST __t13931 = _t;
+ AST tmp39_AST = null;
+ AST tmp39_AST_in = null;
+ tmp39_AST = astFactory.create((AST)_t);
+ tmp39_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp39_AST);
+ ASTPair __currentAST13931 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MAS);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13931;
+ _t = __t13931;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Arit( e1, e2);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case MENOS:
+ {
+ AST __t13932 = _t;
+ AST tmp40_AST = null;
+ AST tmp40_AST_in = null;
+ tmp40_AST = astFactory.create((AST)_t);
+ tmp40_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp40_AST);
+ ASTPair __currentAST13932 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MENOS);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13932;
+ _t = __t13932;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Arit( e1, e2);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case MENOSUNARIO:
+ {
+ AST __t13933 = _t;
+ AST tmp41_AST = null;
+ AST tmp41_AST_in = null;
+ tmp41_AST = astFactory.create((AST)_t);
+ tmp41_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp41_AST);
+ ASTPair __currentAST13933 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MENOSUNARIO);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13933;
+ _t = __t13933;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Una_Arit( e1);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case POR:
+ {
+ AST __t13934 = _t;
+ AST tmp42_AST = null;
+ AST tmp42_AST_in = null;
+ tmp42_AST = astFactory.create((AST)_t);
+ tmp42_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp42_AST);
+ ASTPair __currentAST13934 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,POR);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13934;
+ _t = __t13934;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Arit( e1, e2);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case DIVISION:
+ {
+ AST __t13935 = _t;
+ AST tmp43_AST = null;
+ AST tmp43_AST_in = null;
+ tmp43_AST = astFactory.create((AST)_t);
+ tmp43_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp43_AST);
+ ASTPair __currentAST13935 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,DIVISION);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ e2=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13935;
+ _t = __t13935;
+ _t = _t.getNextSibling();
+ res=AS_Exp_Bin_Arit( e1, e2);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case LLAMADA:
+ {
+ AST __t13936 = _t;
+ AST tmp44_AST = null;
+ AST tmp44_AST_in = null;
+ tmp44_AST = astFactory.create((AST)_t);
+ tmp44_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp44_AST);
+ ASTPair __currentAST13936 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,LLAMADA);
+ _t = _t.getFirstChild();
+ e1=acceso(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ AST __t13937 = _t;
+ AST tmp45_AST = null;
+ AST tmp45_AST_in = null;
+ tmp45_AST = astFactory.create((AST)_t);
+ tmp45_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp45_AST);
+ ASTPair __currentAST13937 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,EXPRESIONES);
+ _t = _t.getFirstChild();
+ l=lista_expresiones(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13937;
+ _t = __t13937;
+ _t = _t.getNextSibling();
+ currentAST = __currentAST13936;
+ _t = __t13936;
+ _t = _t.getNextSibling();
+ res=AS_Llamada( e1, l);
+ if (res != null){
+ if (res.getTipo().getType() == VACIO){
+ System.out.println("ERROR: No se puede recoger el valor devuelto por un procedimiento (no devuelve nada).");
+ System.exit(1);
+ }
+ }
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case ACCESO_TABLA:
+ {
+ AST __t13938 = _t;
+ AST tmp46_AST = null;
+ AST tmp46_AST_in = null;
+ tmp46_AST = astFactory.create((AST)_t);
+ tmp46_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp46_AST);
+ ASTPair __currentAST13938 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,ACCESO_TABLA);
+ _t = _t.getFirstChild();
+ e1=acceso(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ AST __t13939 = _t;
+ AST tmp47_AST = null;
+ AST tmp47_AST_in = null;
+ tmp47_AST = astFactory.create((AST)_t);
+ tmp47_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp47_AST);
+ ASTPair __currentAST13939 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,EXPRESIONES);
+ _t = _t.getFirstChild();
+ l=lista_expresiones_nv(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13939;
+ _t = __t13939;
+ _t = _t.getNextSibling();
+ currentAST = __currentAST13938;
+ _t = __t13938;
+ _t = _t.getNextSibling();
+ res=AS_Acceso_Tabla( e1, l);
+
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case ACCESO_OBJETO:
+ case ACCESO_SIMPLE:
+ {
+ e1=acceso(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ res=e1;
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case LIT_ENTERO:
+ {
+ i = (AST)_t;
+ AST i_AST_in = null;
+ i_AST = astFactory.create(i);
+ astFactory.addASTChild(currentAST, i_AST);
+ match(_t,LIT_ENTERO);
+ _t = _t.getNextSibling();
+ res=AS_Literal( i);
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case LIT_REAL:
+ {
+ j = (AST)_t;
+ AST j_AST_in = null;
+ j_AST = astFactory.create(j);
+ astFactory.addASTChild(currentAST, j_AST);
+ match(_t,LIT_REAL);
+ _t = _t.getNextSibling();
+ res=AS_Literal( j);
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case LIT_CAR:
+ {
+ k = (AST)_t;
+ AST k_AST_in = null;
+ k_AST = astFactory.create(k);
+ astFactory.addASTChild(currentAST, k_AST);
+ match(_t,LIT_CAR);
+ _t = _t.getNextSibling();
+ res=AS_Literal( k);
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case CIERTO:
+ {
+ m = (AST)_t;
+ AST m_AST_in = null;
+ m_AST = astFactory.create(m);
+ astFactory.addASTChild(currentAST, m_AST);
+ match(_t,CIERTO);
+ _t = _t.getNextSibling();
+ res=AS_Literal( m);
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case FALSO:
+ {
+ n = (AST)_t;
+ AST n_AST_in = null;
+ n_AST = astFactory.create(n);
+ astFactory.addASTChild(currentAST, n_AST);
+ match(_t,FALSO);
+ _t = _t.getNextSibling();
+ res=AS_Literal( n);
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case ENTERO_A_REAL:
+ {
+ AST __t13940 = _t;
+ AST tmp48_AST = null;
+ AST tmp48_AST_in = null;
+ tmp48_AST = astFactory.create((AST)_t);
+ tmp48_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp48_AST);
+ ASTPair __currentAST13940 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,ENTERO_A_REAL);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13940;
+ _t = __t13940;
+ _t = _t.getNextSibling();
+ res = AS_Entero_A_Real(e1);
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case REAL_A_ENTERO:
+ {
+ AST __t13941 = _t;
+ AST tmp49_AST = null;
+ AST tmp49_AST_in = null;
+ tmp49_AST = astFactory.create((AST)_t);
+ tmp49_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp49_AST);
+ ASTPair __currentAST13941 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,REAL_A_ENTERO);
+ _t = _t.getFirstChild();
+ e1=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13941;
+ _t = __t13941;
+ _t = _t.getNextSibling();
+ res = AS_Real_A_Entero(e1);
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ case ERROR:
+ {
+ AST tmp50_AST = null;
+ AST tmp50_AST_in = null;
+ tmp50_AST = astFactory.create((AST)_t);
+ tmp50_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp50_AST);
+ match(_t,ERROR);
+ _t = _t.getNextSibling();
+ expresion_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = expresion_AST;
+ _retTree = _t;
+ return res;
+ }
+
+ public final void condicion(AST _t,
+ AST tipodev
+ ) throws RecognitionException {
+
+ AST condicion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST condicion_AST = null;
+ Atr_Expr e;
+
+ try { // for error handling
+ AST __t13914 = _t;
+ AST tmp51_AST = null;
+ AST tmp51_AST_in = null;
+ tmp51_AST = astFactory.create((AST)_t);
+ tmp51_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp51_AST);
+ ASTPair __currentAST13914 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,SI);
+ _t = _t.getFirstChild();
+ e=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ AST __t13915 = _t;
+ AST tmp52_AST = null;
+ AST tmp52_AST_in = null;
+ tmp52_AST = astFactory.create((AST)_t);
+ tmp52_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp52_AST);
+ ASTPair __currentAST13915 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,INSTRUCCIONES);
+ _t = _t.getFirstChild();
+ instrucciones(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13915;
+ _t = __t13915;
+ _t = _t.getNextSibling();
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case INSTRUCCIONES:
+ {
+ AST __t13917 = _t;
+ AST tmp53_AST = null;
+ AST tmp53_AST_in = null;
+ tmp53_AST = astFactory.create((AST)_t);
+ tmp53_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp53_AST);
+ ASTPair __currentAST13917 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,INSTRUCCIONES);
+ _t = _t.getFirstChild();
+ instrucciones(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13917;
+ _t = __t13917;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ currentAST = __currentAST13914;
+ _t = __t13914;
+ _t = _t.getNextSibling();
+ AS_Condicional(e);
+
+ condicion_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = condicion_AST;
+ _retTree = _t;
+ }
+
+ public final void iteracion(AST _t,
+ AST tipodev
+ ) throws RecognitionException {
+
+ AST iteracion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST iteracion_AST = null;
+ Atr_Expr e;
+
+ try { // for error handling
+ AST __t13919 = _t;
+ AST tmp54_AST = null;
+ AST tmp54_AST_in = null;
+ tmp54_AST = astFactory.create((AST)_t);
+ tmp54_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp54_AST);
+ ASTPair __currentAST13919 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,MIENTRAS);
+ _t = _t.getFirstChild();
+ e=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ AST __t13920 = _t;
+ AST tmp55_AST = null;
+ AST tmp55_AST_in = null;
+ tmp55_AST = astFactory.create((AST)_t);
+ tmp55_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp55_AST);
+ ASTPair __currentAST13920 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,INSTRUCCIONES);
+ _t = _t.getFirstChild();
+ instrucciones(_t,tipodev);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13920;
+ _t = __t13920;
+ _t = _t.getNextSibling();
+ currentAST = __currentAST13919;
+ _t = __t13919;
+ _t = _t.getNextSibling();
+ AS_Condicional(e);
+
+ iteracion_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = iteracion_AST;
+ _retTree = _t;
+ }
+
+ public final Atr_Expr acceso(AST _t) throws RecognitionException {
+ Atr_Expr res=null;
+
+ AST acceso_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST acceso_AST = null;
+ AST r_AST = null;
+ AST r = null;
+ AST a = null;
+ AST a_AST = null;
+ Atr_Expr e;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ACCESO_SIMPLE:
+ {
+ e=acceso_simple(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ res=e;
+ acceso_AST = (AST)currentAST.root;
+ break;
+ }
+ case ACCESO_OBJETO:
+ {
+ AST __t13943 = _t;
+ AST tmp56_AST = null;
+ AST tmp56_AST_in = null;
+ tmp56_AST = astFactory.create((AST)_t);
+ tmp56_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp56_AST);
+ ASTPair __currentAST13943 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,ACCESO_OBJETO);
+ _t = _t.getFirstChild();
+ r = _t==ASTNULL ? null : (AST)_t;
+ e=acceso_simple(_t);
+ _t = _retTree;
+ r_AST = (AST)returnAST;
+ astFactory.addASTChild(currentAST, returnAST);
+ a = (AST)_t;
+ AST a_AST_in = null;
+ a_AST = astFactory.create(a);
+ astFactory.addASTChild(currentAST, a_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ currentAST = __currentAST13943;
+ _t = __t13943;
+ _t = _t.getNextSibling();
+
+ res=AS_Acceso_Objeto( e, r, a);
+
+ acceso_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = acceso_AST;
+ _retTree = _t;
+ return res;
+ }
+
+ public final LinkedList lista_expresiones(AST _t) throws RecognitionException {
+ LinkedList l= new LinkedList();
+
+ AST lista_expresiones_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST lista_expresiones_AST = null;
+ Atr_Expr e;
+
+ try { // for error handling
+ {
+ _loop13912:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_tokenSet_0.member(_t.getType()))) {
+ e=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ l.add(e);
+ }
+ else {
+ break _loop13912;
+ }
+
+ } while (true);
+ }
+ lista_expresiones_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = lista_expresiones_AST;
+ _retTree = _t;
+ return l;
+ }
+
+ public final LinkedList lista_expresiones_nv(AST _t) throws RecognitionException {
+ LinkedList l= new LinkedList();
+
+ AST lista_expresiones_nv_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST lista_expresiones_nv_AST = null;
+ Atr_Expr e;
+
+ try { // for error handling
+ {
+ int _cnt13949=0;
+ _loop13949:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_tokenSet_0.member(_t.getType()))) {
+ e=expresion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ l.add(e);
+ }
+ else {
+ if ( _cnt13949>=1 ) { break _loop13949; } else {throw new NoViableAltException(_t);}
+ }
+
+ _cnt13949++;
+ } while (true);
+ }
+ lista_expresiones_nv_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = lista_expresiones_nv_AST;
+ _retTree = _t;
+ return l;
+ }
+
+ public final Atr_Expr acceso_simple(AST _t) throws RecognitionException {
+ Atr_Expr res=null;
+
+ AST acceso_simple_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST acceso_simple_AST = null;
+ AST d_AST = null;
+ AST d = null;
+
+ try { // for error handling
+ AST __t13945 = _t;
+ AST tmp57_AST = null;
+ AST tmp57_AST_in = null;
+ tmp57_AST = astFactory.create((AST)_t);
+ tmp57_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp57_AST);
+ ASTPair __currentAST13945 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,ACCESO_SIMPLE);
+ _t = _t.getFirstChild();
+ AST tmp58_AST = null;
+ AST tmp58_AST_in = null;
+ tmp58_AST = astFactory.create((AST)_t);
+ tmp58_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp58_AST);
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ d = _t==ASTNULL ? null : (AST)_t;
+ declaracion_acceso(_t);
+ _t = _retTree;
+ d_AST = (AST)returnAST;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13945;
+ _t = __t13945;
+ _t = _t.getNextSibling();
+ res=AS_Acceso_Simple(d_AST);
+ acceso_simple_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = acceso_simple_AST;
+ _retTree = _t;
+ return res;
+ }
+
+ public final void declaracion_acceso(AST _t) throws RecognitionException {
+
+ AST declaracion_acceso_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST declaracion_acceso_AST = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case MODULO:
+ {
+ declaracion_modulo(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ declaracion_acceso_AST = (AST)currentAST.root;
+ break;
+ }
+ case CLASE:
+ {
+ declaracion_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ declaracion_acceso_AST = (AST)currentAST.root;
+ break;
+ }
+ case ATRIBUTO:
+ case METODO:
+ {
+ declaracion_elemento_clase(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ declaracion_acceso_AST = (AST)currentAST.root;
+ break;
+ }
+ case PARAMETRO:
+ {
+ declaracion_parametro(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ declaracion_acceso_AST = (AST)currentAST.root;
+ break;
+ }
+ case VARIABLE_LOCAL:
+ {
+ declaracion_variable_local(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ declaracion_acceso_AST = (AST)currentAST.root;
+ break;
+ }
+ case ERROR:
+ {
+ declaracion_error(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ declaracion_acceso_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = declaracion_acceso_AST;
+ _retTree = _t;
+ }
+
+ public final void tipo_predefinido_simple(AST _t) throws RecognitionException {
+
+ AST tipo_predefinido_simple_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST tipo_predefinido_simple_AST = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ENTERO:
+ {
+ AST tmp59_AST = null;
+ AST tmp59_AST_in = null;
+ tmp59_AST = astFactory.create((AST)_t);
+ tmp59_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp59_AST);
+ match(_t,ENTERO);
+ _t = _t.getNextSibling();
+ tipo_predefinido_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ case REAL:
+ {
+ AST tmp60_AST = null;
+ AST tmp60_AST_in = null;
+ tmp60_AST = astFactory.create((AST)_t);
+ tmp60_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp60_AST);
+ match(_t,REAL);
+ _t = _t.getNextSibling();
+ tipo_predefinido_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ case LOGICO:
+ {
+ AST tmp61_AST = null;
+ AST tmp61_AST_in = null;
+ tmp61_AST = astFactory.create((AST)_t);
+ tmp61_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp61_AST);
+ match(_t,LOGICO);
+ _t = _t.getNextSibling();
+ tipo_predefinido_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ case CARACTER:
+ {
+ AST tmp62_AST = null;
+ AST tmp62_AST_in = null;
+ tmp62_AST = astFactory.create((AST)_t);
+ tmp62_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp62_AST);
+ match(_t,CARACTER);
+ _t = _t.getNextSibling();
+ tipo_predefinido_simple_AST = (AST)currentAST.root;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = tipo_predefinido_simple_AST;
+ _retTree = _t;
+ }
+
+ public final void tipo_predefinido_compuesto(AST _t) throws RecognitionException {
+
+ AST tipo_predefinido_compuesto_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST tipo_predefinido_compuesto_AST = null;
+
+ try { // for error handling
+ formacion(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ tipo_predefinido_compuesto_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = tipo_predefinido_compuesto_AST;
+ _retTree = _t;
+ }
+
+ public final void formacion(AST _t) throws RecognitionException {
+
+ AST formacion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST formacion_AST = null;
+ AST t=null;
+
+ try { // for error handling
+ AST __t13954 = _t;
+ AST tmp63_AST = null;
+ AST tmp63_AST_in = null;
+ tmp63_AST = astFactory.create((AST)_t);
+ tmp63_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp63_AST);
+ ASTPair __currentAST13954 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,FORMACION);
+ _t = _t.getFirstChild();
+ AST __t13955 = _t;
+ AST tmp64_AST = null;
+ AST tmp64_AST_in = null;
+ tmp64_AST = astFactory.create((AST)_t);
+ tmp64_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp64_AST);
+ ASTPair __currentAST13955 = currentAST.copy();
+ currentAST.root = currentAST.child;
+ currentAST.child = null;
+ match(_t,LISTA_ENTEROS);
+ _t = _t.getFirstChild();
+ lista_enteros(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ currentAST = __currentAST13955;
+ _t = __t13955;
+ _t = _t.getNextSibling();
+ {
+ tipo_predefinido_simple(_t);
+ _t = _retTree;
+ astFactory.addASTChild(currentAST, returnAST);
+ }
+ currentAST = __currentAST13954;
+ _t = __t13954;
+ _t = _t.getNextSibling();
+ formacion_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = formacion_AST;
+ _retTree = _t;
+ }
+
+ public final void lista_enteros(AST _t) throws RecognitionException {
+
+ AST lista_enteros_AST_in = (_t == ASTNULL) ? null : (AST)_t;
+ returnAST = null;
+ ASTPair currentAST = new ASTPair();
+ AST lista_enteros_AST = null;
+
+ try { // for error handling
+ {
+ int _cnt13959=0;
+ _loop13959:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==LIT_ENTERO)) {
+ AST tmp65_AST = null;
+ AST tmp65_AST_in = null;
+ tmp65_AST = astFactory.create((AST)_t);
+ tmp65_AST_in = (AST)_t;
+ astFactory.addASTChild(currentAST, tmp65_AST);
+ match(_t,LIT_ENTERO);
+ _t = _t.getNextSibling();
+ }
+ else {
+ if ( _cnt13959>=1 ) { break _loop13959; } else {throw new NoViableAltException(_t);}
+ }
+
+ _cnt13959++;
+ } while (true);
+ }
+ lista_enteros_AST = (AST)currentAST.root;
+ }
+ catch (RecognitionException ex) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ }
+ returnAST = lista_enteros_AST;
+ _retTree = _t;
+ }
+
+
+ public static final String[] _tokenNames = {
+ "<0>",
+ "EOF",
+ "<2>",
+ "NULL_TREE_LOOKAHEAD",
+ "PROGRAMA",
+ "VISIBLE",
+ "OCULTO",
+ "NO_INST",
+ "ATRIBUTO",
+ "METODO",
+ "PROTOTIPO",
+ "PARAMETRO",
+ "PARAMETROS",
+ "EXPRESIONES",
+ "RESULTADO",
+ "DEFINICION",
+ "VACIO",
+ "VARIABLE_LOCAL",
+ "VARIABLES_LOCALES",
+ "INSTRUCCION",
+ "INSTRUCCIONES",
+ "MENOSUNARIO",
+ "LLAMADA",
+ "ACCESO_TABLA",
+ "ACCESO_OBJETO",
+ "ACCESO_SIMPLE",
+ "LISTA_ENTEROS",
+ "ERROR",
+ "MODULO",
+ "IDENT",
+ "COMA",
+ "IMPORTACION",
+ "DOS_PUNTOS",
+ "EXPORTACION",
+ "IMPLEMENTACION",
+ "INST",
+ "CLASE",
+ "LLAVE_ABIERTA",
+ "LLAVE_CERRADA",
+ "PARENTESIS_ABIERTO",
+ "PUNTO_Y_COMA",
+ "PARENTESIS_CERRADO",
+ "DEV",
+ "ASIGNACION",
+ "CREAR",
+ "SI",
+ "ENTONCES",
+ "SINO",
+ "FINSI",
+ "MIENTRAS",
+ "HACER",
+ "FINMIENTRAS",
+ "O",
+ "Y",
+ "NO",
+ "MAYOR",
+ "MAYOR_IGUAL",
+ "MENOR",
+ "MENOR_IGUAL",
+ "IGUAL",
+ "DISTINTO",
+ "MAS",
+ "MENOS",
+ "POR",
+ "DIVISION",
+ "CORCHETE_ABIERTO",
+ "LIT_ENTERO",
+ "LIT_REAL",
+ "LIT_CAR",
+ "CIERTO",
+ "FALSO",
+ "CORCHETE_CERRADO",
+ "PUNTO",
+ "ENTERO",
+ "REAL",
+ "LOGICO",
+ "CARACTER",
+ "FORMACION",
+ "ESCRIBIR",
+ "ENTERO_A_REAL",
+ "REAL_A_ENTERO"
+ };
+
+ private static final long[] mk_tokenSet_0() {
+ long[] data = { -4503599428141056L, 98429L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
+ }
+