Main { (@ /** Prints all edges in a given class graph. A program to show second order visitors. Requires a visitor to traverse a visitor. */ public static void main(String args[]) throws Exception { Program p = Program.parse(System.in); int result = p.print_edges(); System.out.println(" construction edges = " + result); if (result == 1) { System.out.println("SUCCESS"); } else { System.out.println("FAILURE"); } } @) } Program { (@ /** Prints all edges in a given class graph. A program to show second order visitors. Requires a visitor to traverse a visitor. */ public static void main(String args[]) throws Exception { Program p = parse(System.in); p.print_edges(); } @) (@ public int print_edges () { ClassNameTranspVisitor cntv = new ClassNameTranspVisitor(); EdgeVisitor aev = new EdgeVisitor(cntv); EdgeDistinctionVisitor edv = new EdgeDistinctionVisitor(0,0); this.toAllSubclasses(edv,cntv,aev); return edv.get_c(); } @) traversal toAllSubclasses( EdgeDistinctionVisitor edv, ClassNameTranspVisitor cntv, EdgeVisitor aev ) { to {Subclass, Part}; } } ClassNameTranspVisitor { before ClassDef (@ this.set_pcn(host.get_paramclassname()); @)} ClassNameRetVisitor { before ClassName (@ this.set_cn(host); @)} EdgeDistinctionVisitor { before Part (@ System.out.println( " construction edge "); c = c + 1; @) before Subclass (@ System.out.println( " alternation edge "); a = a + 1; @) } EdgeVisitor { traversal toClassName( ClassNameRetVisitor cnrv) { bypassing -> *,parameters,* to ClassName;} (@ /** Retrieve the class name from the visitor. Requires a traversal from the visitor class which itself needs a visitor. */ public ClassName dig_out() { ClassNameRetVisitor cnrv = new ClassNameRetVisitor(); this.toClassName(cnrv); return cnrv.get_cn(); } @) before {Part,Subclass} (@ System.out.println( " source of edge " + this.dig_out().get_name() + "\n" + " target of edge " + host.get_classspec(). get_classname(). get_name()); @) // before Subclass // (@ System.out.println( // " source of alternation edge " + // this.dig_out().get_name() + "\n" + // " target of alternation edge " + // host.get_classspec(). // get_classname(). // get_name()); // // @) }