CompilationUnit { traversal Constructed(ConRevVisitor crV) { through {CBD_FieldDeclaration, CM_Abstract} through {Type, CAbstract} to {CAbstract,boolType,byteType,charType,shortType,intType,floatType,longType,doubleType,Identifier}; } traversal Alternat(AltRevVisitor altV) { through ExtendName to Identifier; } (@ void PrintClassGraph() { AltRevVisitor altV = new AltRevVisitor(); this.Alternat(altV); ConRevVisitor crV = new ConRevVisitor(); crV.set_altV(altV); this.Constructed(crV); } @) } AltRevVisitor { init (@ alt_hash = new Hashtable(); @) before UnmodifiedClassDeclaration (@ class_name = host.get_ident(); @) before Identifier (@ Vector alt_vec = new Vector(); Ident alt_class = host.get_ident(); if (alt_class != null) { if (alt_hash.containsKey(alt_class)) { alt_vec = (Vector)alt_hash.get(alt_class); } alt_vec.addElement(class_name); alt_hash.put(alt_class, alt_vec); } @) (@ public void print_alternates(Ident i) { Vector alt_vec = new Vector(); alt_vec = (Vector)alt_hash.get(i); Enumeration elem = alt_vec.elements(); while (elem.hasMoreElements()) { System.out.print(elem.nextElement()); if (elem.hasMoreElements()) System.out.print(" | "); } } @) } ConRevVisitor { before ClassDeclaration (@ abstract_class = false; first_variable = true; @) before CAbstract (@ abstract_class = true; @) before UnmodifiedClassDeclaration (@ System.out.print(host.get_ident()); if (abstract_class) { System.out.print(" : "); altV.print_alternates(host.get_ident()); } else { System.out.print(" = "); } @) before Type (@ if (abstract_class && first_variable) { System.out.print(" *common* "); first_variable = false; } @) before boolType (@ System.out.print("boolean "); @) before byteType (@ System.out.print("byte "); @) before charType (@ System.out.print("char "); @) before shortType (@ System.out.print("short "); @) before intType (@ System.out.print("int "); @) before floatType (@ System.out.print("float "); @) before longType (@ System.out.print("long "); @) before doubleType (@ System.out.print("double "); @) before Identifier (@ System.out.print(host.get_ident() + " "); @) after UnmodifiedClassDeclaration (@ System.out.println("."); @) } Main { (@ public static void main(String args[]) throws Exception { CompilationUnit program = CompilationUnit.parse(System.in); program.PrintClassGraph(); } @) }