1 import antlr.ASTFactory;
2 import antlr.collections.AST;
10 public Modulo(String nombre, AST arbol){
12 this.exportacion = null;
13 this.importacion = null;
15 AST t = arbol.getFirstChild();
17 if(t.getText().equals("exportacion")){
18 ASTFactory f = new ASTFactory();
19 this.exportacion = f.dupTree(t);
21 if(t.getText().equals("importacion")){
22 ASTFactory f = new ASTFactory();
23 this.importacion = f.dupTree(t);
25 t = t.getNextSibling();
29 public String getNombre() {
32 public void setNombre(String nombre) {
35 public AST getExportacion() {
38 public void setExportacion(AST exportacion) {
39 this.exportacion = exportacion;
41 public AST getDeclaracion(String nombre){
42 AST arbol = exportacion.getFirstChild();
43 while(!arbol.getFirstChild().getText().equals(nombre)){
44 arbol = arbol.getNextSibling();
50 public AST getImportacion(){
54 public String referenciaCiclica(TablaModulos mods){
58 String minombre =nombre;
59 if(importacion != null)
60 arbol = importacion.getFirstChild();
63 Modulo mod = mods.get(arbol.getText());
64 if(mod.getNombre().equals(nombre)){
65 return nombre + "->" + mod.getNombre();
67 ref2 = referenciaCiclica(mod, mods);
69 return nombre + "->" + ref2;
71 arbol = arbol.getNextSibling();
77 public String referenciaCiclica(Modulo mod, TablaModulos mods){
78 if(mod.getNombre().equals(nombre)){
79 return mod.getNombre();
81 AST arbol = mod.getImportacion();
83 arbol = arbol.getFirstChild();
86 Modulo mod1 = mods.get(arbol.getText());
87 if(mod1.getNombre().equals(nombre)){
88 return mod.getNombre() + "->" + mod1.getNombre();
90 String ref2 =referenciaCiclica(mod1, mods);
92 return mod.getNombre() + "->" + ref2;
95 arbol = arbol.getNextSibling();