public Body body;
public void toHTML(ToHTML.HTML sb) { sb.tag("html", body); }
public static class Header extends HashMap<String, Text[]> {
- public static class kv { public String key; public Text[] val; }
- public void attrs(kv[] kvs) { for(int i=0; i<kvs.length; i++) this.put(kvs[i].key, kvs[i].val); }
+ public static class KeyVal { public String key; public Text[] val; }
+ public void attrs(KeyVal[] KeyVals) { for(int i=0; i<KeyVals.length; i++) this.put(KeyVals[i].key, KeyVals[i].val); }
}
public static class Body implements ToHTML {
public Section[] sections;
// Main //////////////////////////////////////////////////////////////////////////////
+ public static class Dump implements Reflection.Show {
+ public String toString() { return Reflection.show(this); }
+ }
+
public static class TD {
- public @nonterminal("Doc") static class Doc {
- public @arg("head") Header head;
- public @arg("body") Body body;
- public String toString() { return "doc:{"+head+","/*+body*/+"}"; }
+ public @nonterminal static class Doc extends Dump {
+ public @arg Header head;
+ public @arg Body body;
}
- public @nonterminal("Header") static class Header {
- public @arg("attrs") KV[] attrs;
+ public @nonterminal static class Header extends Dump {
+ public @arg KeyVal[] attrs;
// FIXME: it would be nice to be able to
- // void kv(String, String) { ... } imperatively
- public String toString() {
- StringBuffer ret = new StringBuffer();
- ret.append("<");
- for(KV kv : attrs) ret .append(kv);
- ret.append(">");
- return ret.toString();
- }
+ // void KeyVal(String, String) { ... } imperatively
}
- public @nonterminal("Body") static class Body {
- public Object[] sections;
- // FIXME: it would be nice to be able to
- // void kv(String, String) { ... } imperatively
- public String toString() {
- StringBuffer ret = new StringBuffer();
- ret.append("<");
- for(Object kv : sections) ret .append(kv);
- ret.append(">");
- return ret.toString();
- }
+ public @nonterminal static class Body extends Dump {
+ public Section[] sections;
}
- public @nonterminal("kv") static class KV {
- public @arg("key") String key;
- public @arg("val") Object val;
- public String toString() { return "KV["+key+"="+val+"]"; }
+ public @nonterminal("Section") static class Section extends Dump {
+ public String header;
+ public Paragraph[] paragraphs;
+ }
+
+ public @nonterminal static class KeyVal extends Dump {
+ public @arg String key;
+ public @arg Object val;
+ }
+
+ public static class Paragraph extends Dump { }
+ public @tag("P") static class P extends Paragraph {
+ Object text;
+ }
+ public @tag("HR") static class HR extends Paragraph { }
+ public @tag("Blockquote") static class Blockquote extends Paragraph {
+ Object text;
}
}
new Class[] {
TibDoc.TD.Doc.class,
TibDoc.TD.Header.class,
+ TibDoc.TD.Section.class,
TibDoc.TD.Body.class,
- TibDoc.TD.KV.class
+ TibDoc.TD.Paragraph.class,
+ TibDoc.TD.P.class,
+ TibDoc.TD.HR.class,
+ TibDoc.TD.Blockquote.class,
+ TibDoc.TD.KeyVal.class
});
Tree<String> res = new CharParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1();
MetaGrammar.Meta.MetaGrammarFile mgf = m.new MetaGrammarFile(res);