// WALK TREE AND REWRITE TOKEN BUFFER
// get the tree from the return structure for rule prog
CommonTree t = (CommonTree)r.getTree();
// create a stream of tree nodes from AST built by parser
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
// tell it where it can find the token objects
nodes.setTokenStream(tokens);
Gen gen = new Gen(nodes);
gen.program(); // invoke rule program
System.out.println(tokens.toString()); // emit tweaked token buffer
}