EquationSystem{ (@ void f() { V1 v1 = new V1(null, new Integer(0)); t1(v1); int result = v1.get_c().intValue(); if(result == 4) { System.out.println("SUCCESS"); } else { System.out.println("FAILURE"); } } @) (@ void g(Variable w) { // creates a new visitor object for each call // better would be // V2 v2 = Visitors.v2; // v2.set_var(w); V2 v2 = new V2(new Equation(), w); t2(v2); } @) traversal t1(V1 v1) { bypassing Exp to Variable;} traversal t2(V2 v2) { // the following shoul also work, but doesn't. A bug? bypassing {-> *,var,*} // bypassing {-> Equation,var,Variable} to Variable;} } V1{ before EquationSystem (@ e = host; @) before Variable (@ this.set_c(new Integer(this.get_c().intValue() + 1)); // find out where used System.out.println(" V1 " + host.get_variableName().toString()); e.g(host); @) } V2{ before * (@ System.out.println("V2 is in " +host.getClass().toString()); @) before Equation (@ equation = host; @) before Variable (@ System.out.println(" V2 variable " + host.get_variableName().toString()); if (host.get_variableName().equals(variable.get_variableName())) { System.out.println(" V2 " + host.get_variableName().toString() + " is used in an equation"); } @) } Main { (@ static public void main(String args[]) throws Exception { EquationSystem e = EquationSystem.parse(System.in); e.f(); System.out.println("done: "); } @) }