// generated by program in: // http://www.ccs.neu.edu/research/demeter/sources/DemeterJava/examples/j-gprint // output simplified A { void g_print2() (@ PrintingVisitor2 pv = new PrintingVisitor2(); this.t(pv); @) void g_print() to * (PrintVisitor); // should work but does not yet // instead use temporarily void g_print_temp() (@ StringWriter w = new StringWriter(); PrintVisitor p = new PrintVisitor(new PrintWriter(w)); this.universal_trv0(p); System.out.println(w); @) void display() to * (DisplayVisitor); int countG() to * { // use inlined visitor (@ int total; @) init (@ total = 0; @) before G (@ total = total + 1; @) return int (@ total @) } traversal t(PrintingVisitor2 pv) {to *;} } Main { (@ static public void main(String args[]) throws Exception { A a = A.parse(System.in); System.out.println("print:"); a.g_print2(); System.out.println("print again:"); a.g_print(); System.out.println("print again:"); a.g_print_temp(); System.out.println(" end of printing"); System.out.println("tree structure:"); a.display(); System.out.println(); System.out.println("count:"); int result = a.countG(); System.out.println(result + " done "); } @) } PrintingVisitor2{ before A (@ System.out.print(" a "); @) after A (@ System.out.print(" enda "); @) before D (@ System.out.print(" d "); @) before E (@ System.out.print(" e "); @) before H (@ System.out.print(" h "); @) }