1 import antlr.ASTFactory;
2 import antlr.collections.AST;
11 public Modulo(String nombre, AST arbol){
13 this.exportacion = null;
14 this.importacion = null;
16 AST t = arbol.getFirstChild();
18 if(t.getText().equals("exportacion")){
19 ASTFactory f = new ASTFactory();
20 this.exportacion = f.dupTree(t);
22 if(t.getText().equals("importacion")){
23 ASTFactory f = new ASTFactory();
24 this.importacion = f.dupTree(t);
26 if(t.getText().equals("implementacion")){
27 ASTFactory f = new ASTFactory();
28 this.implementacion = f.dupTree(t);
30 t = t.getNextSibling();
34 public String getNombre() {
37 public void setNombre(String nombre) {
40 public AST getExportacion() {
43 public void setExportacion(AST exportacion) {
44 this.exportacion = exportacion;
46 public AST getDeclaracion(String nombre){
47 AST arbol = exportacion.getFirstChild();
48 while(!arbol.getFirstChild().getText().equals(nombre)){
49 arbol = arbol.getNextSibling();
56 public AST getDeclaracion_interna(String nombre){
57 AST arbol = implementacion.getFirstChild();
58 while(!arbol.getFirstChild().getText().equals(nombre)){
59 arbol = arbol.getNextSibling();
66 public AST getImportacion(){
70 public String referenciaCiclica(TablaModulos mods){
74 String minombre =nombre;
75 if(importacion != null)
76 arbol = importacion.getFirstChild();
79 Modulo mod = mods.get(arbol.getText());
80 if(mod.getNombre().equals(nombre)){
81 return nombre + "->" + mod.getNombre();
83 ref2 = referenciaCiclica(mod, mods);
85 return nombre + "->" + ref2;
87 arbol = arbol.getNextSibling();
93 public String referenciaCiclica(Modulo mod, TablaModulos mods){
94 if(mod.getNombre().equals(nombre)){
95 return mod.getNombre();
97 AST arbol = mod.getImportacion();
99 arbol = arbol.getFirstChild();
101 while(arbol != null){
102 Modulo mod1 = mods.get(arbol.getText());
103 if(mod1.getNombre().equals(nombre)){
104 return mod.getNombre() + "->" + mod1.getNombre();
106 String ref2 =referenciaCiclica(mod1, mods);
107 if(!ref2.equals("")){
108 return mod.getNombre() + "->" + ref2;
111 arbol = arbol.getNextSibling();