// In phase 3, a great deal of this code is eliminated and written in a // more efficient and condensed form Root { traversal all(AppendVisitor av) { to {RootClass,SubClass1,SubClass2}; } (@ Names Find_Name() { AppendVisitor av = new AppendVisitor(new Names()); this.all(av); return av.get_names(); } @) } Expected { traversal Get_Expected(ExpectedVisitor ev) { to {Expected_Wrapper}; } (@ Names Fill_Vector() { ExpectedVisitor ev = new ExpectedVisitor(new Names()); this.Get_Expected(ev); return ev.get_list(); } @) } // The following code using slot_name() is deleted in phase3 in favor // of code in the visitors using the generated functions get_className and // get_wrapperName Root { (@ Ident slot_name() { return className; } @) } Non_Empty_RootClass { (@ Ident slot_name() { return className; } @) } Non_Empty_SubClass1 { (@ Ident slot_name() { return className; } @) } Non_Empty_SubClass2 { (@ Ident slot_name() { return className; } @) } Expected_Wrapper { (@ Ident slot_name() { return wrapper_name; } @) } // end of code removed in phase 3 Names { (@ public boolean s_equals(Names result2) { Enumeration a = this.elements(); Enumeration b = result2.elements(); boolean r = false; while (a.hasMoreElements()) { if(b.hasMoreElements()) r = true; else { r = false; break; } if(b.nextElement().toString().equals(a.nextElement().toString())) r = true; else { r = false; break; } } return r; } public void print_names() { Enumeration a = this.elements(); System.out.println("\n"); while (a.hasMoreElements()) { System.out.println(" " + a.nextElement().toString()); } } @) } Main { (@ static public void main (String args[]) throws Exception { InputStream in1, in2; in1 = new FileInputStream(args[0]); in2 = new FileInputStream(args[1]); Root in_put = Root.parse(in1); Expected ex = Expected.parse(in2); Names result1 = in_put.Find_Name(); Names result2 = ex.Fill_Vector(); result1.print_names(); result2.print_names(); if(result1.s_equals(result2)) System.out.println("Sucess!"); else System.out.println("Failure!"); } @) } // In phase 3, combined all before and after wrappers into one before and // one after wrapper and added before and after edge wrappers AppendVisitor { before Root (@ this.get_names().addElement(host.slot_name()); @) after Root (@ this.get_names().addElement(host.slot_name()); @) before Non_Empty_RootClass (@ this.get_names().addElement(host.slot_name()); @) after Non_Empty_RootClass (@ this.get_names().addElement(host.slot_name()); @) before Non_Empty_SubClass1 (@ this.get_names().addElement(host.slot_name()); @) after Non_Empty_SubClass1 (@ this.get_names().addElement(host.slot_name()); @) before Non_Empty_SubClass2 (@ this.get_names().addElement(host.slot_name()); @) after Non_Empty_SubClass2 (@ this.get_names().addElement(host.slot_name()); @) } ExpectedVisitor { before Expected_Wrapper (@ this.get_list().addElement(host.slot_name()); @) }