}
public boolean isTransparent() { return false; }
public boolean isHidden() { return false; }
+
+ public static interface TreeFunctor<T,R> extends Functor<Iterable<Tree<T>>, R> {
+ }
+
+ public static class ArrayBuildingTreeFunctor<T> implements TreeFunctor<T,T[]> {
+ public String toString() { return ""; }
+ public T[] invoke(Iterable<Tree<T>> t) {
+ ArrayList ret = new ArrayList();
+ for(Tree tc : t) {
+ if (tc.head() != null && tc.head() instanceof Functor)
+ ret.add(((Functor<Iterable<Tree>,Object>)tc.head()).invoke(tc.children()));
+ else if (tc.numChildren() == 0)
+ ret.add(tc.head());
+ else {
+ System.err.println("FIXME: don't know what to do about " + tc);
+ ret.add(null);
+ }
+ }
+ return (T[])ret.toArray(new Object[0]);
+ }
+ }
}
return false;
}
public Object repeatTag() {
- return new Functor<Iterable<Tree>,Object>() {
- public String toString() { return ""; }
- public Object invoke(Iterable<Tree> t) {
- ArrayList ret = new ArrayList();
- for(Tree tc : t) {
- if (tc.head() != null && tc.head() instanceof Functor)
- ret.add(((Functor<Iterable<Tree>,Object>)tc.head()).invoke(tc.children()));
- else if (tc.numChildren() == 0)
- ret.add(tc.head());
- else {
- System.err.println("FIXME: don't know what to do about " + tc);
- ret.add(null);
- }
- }
- return ret.toArray(new Object[0]);
- }
- };
+ return new Tree.ArrayBuildingTreeFunctor<Object>();
}
public Sequence tryResolveTag(String tag, String nonTerminalName, Element[] els, Object[] labels, boolean[] drops) {
Production p = new Production(tag, nonTerminalName, els, labels, drops);
System.out.println();
System.out.println(f.expand1().toPrettyString());
System.out.println();
- Doc doc = (Doc)new ReflectiveGrammar(TibDoc.class).build(f.expand1());
- System.out.println(doc);
- System.out.println();
- System.out.println();
- System.out.println();
- System.out.println();
- StringBuffer sb = new StringBuffer();
- doc.toHTML(new ToHTML.HTML(sb));
- System.out.println(sb);
+
FileOutputStream fos = new FileOutputStream("out.html");
PrintWriter p = new PrintWriter(new OutputStreamWriter(fos));