+ public static class HTMLWalker extends ReflectiveWalker {
+ public void stringify() { /*mode = HEADER;*/throw new Error(); }
+ public Object walk(Tree<String> t) {
+ String head = t.head();
+ if ("stringify".equals(head)) {
+ StringBuffer ret = new StringBuffer();
+ for(Tree<String> child : t.child(0)) ret.append(child);
+ return new Tree<String>(null, ret.toString());
+ }
+ return super.walk(t);
+ }
+ public Object walk(String head, Object[] children) {
+ if (children.length==0) return new Tree<String>(null, head, new Tree[0]);
+ return new Tree<String>(null, head, (Tree<String>[])Reflection.lub(children));
+ }
+ }