checkpoint
[sbp.git] / src / edu / berkeley / sbp / tib / TibDoc.java
index 5901fcc..ee1a861 100644 (file)
@@ -518,6 +518,7 @@ toContex ll = prefix ++ (concatMap tl ll) ++ suffix
         public static @bind.as("tm") class Tm extends Glyph { public void toHTML(HTML h) { h.appendLiterally("&;"); } }
         public static @bind.as("euro") class Euro extends Glyph { public void toHTML(HTML h) { h.appendLiterally("€"); } }
 
+        public static @bind.as("#") Text comment() { return new Chars(""); }
         public static class Entity extends Text implements ToHTML {
             public int code;
             public String name;
@@ -611,12 +612,13 @@ toContex ll = prefix ++ (concatMap tl ll) ++ suffix
         public static class Link extends Text {
             public Text[] t;
             public Url u;
-            public @bind.as("link")  Link(@bind.arg Text[] t, @bind.arg Url u)  { this.t = t; this.u = u; }
-            public Link(String s, Url u) { this(new Text[] { new Chars(s) }, u); }
+            public Input.Region region;
+            public @bind.as("link")  Link(Input.Region region, @bind.arg Text[] t, @bind.arg Url u)  { this.region = region; this.t = t; this.u = u; }
+            public Link(String s, Url u) { this(null,new Text[] { new Chars(s) }, u); }
             public void toHTML(HTML h) {
                 h.tag("a",
                       new Object[] { "href", u==null ? "" : u.toString() },
-                      new P(t));
+                      new P(/*t*/region+""));
             }
         }
 
@@ -682,9 +684,11 @@ toContex ll = prefix ++ (concatMap tl ll) ++ suffix
     public static void main(String[] s) throws Exception {
         try {
 
-            Tree<String> res = new CharParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1();
+            Tree<String> res = new CharParser(MetaGrammar.newInstance()).parse(new FileInputStream(s[0])).expand1();
             
-            Union tibgram = MetaGrammar.make(res, "s", new AnnotationGrammarBindingResolver(TD.class));
+            AnnotationGrammarBindings resolver = new AnnotationGrammarBindings(TD.class);
+            resolver.add(MetaGrammarBindings.class, "meta");
+            Union tibgram = Grammar.create(res, "s", resolver);
 
             System.err.println("parsing " + s[1]);
             Tree t = new CharParser(tibgram).parse(new Tib(new FileInputStream(s[1]))).expand1();