checkpoint
authoradam <adam@megacz.com>
Thu, 12 Jan 2006 10:24:58 +0000 (05:24 -0500)
committeradam <adam@megacz.com>
Thu, 12 Jan 2006 10:24:58 +0000 (05:24 -0500)
darcs-hash:20060112102458-5007d-57688d3c8cdb8f0a4b303022d832ac4433f7570e.gz

src/edu/berkeley/sbp/Ambiguous.java
src/edu/berkeley/sbp/tib/TibDoc.java
tests/input.tibdoc
tests/tibdoc.g

index 56e1af7..cb55ffa 100644 (file)
@@ -7,13 +7,13 @@ import java.util.*;
 
 /** if ambiguity checking is enabled, this exception is thrown to signal that the parse was ambiguous */
 public class Ambiguous extends RuntimeException {
-    public final Forest ambiguity;
-    public Ambiguous(Forest ambiguity) { this.ambiguity = ambiguity; }
+    public final Forest<?> ambiguity;
+    public Ambiguous(Forest<?> ambiguity) { this.ambiguity = ambiguity; }
     public String toString() {
         StringBuffer sb = new StringBuffer();
         sb.append("unresolved ambiguity "/*"at " + ambiguity.getLocation() + ":"*/);
-        for(Object result : ambiguity.expand(false))
-            sb.append("\n    " + result);
+        for(Tree<?> result : ambiguity.expand(false))
+            sb.append("\n\n" + result.toPrettyString());
         return sb.toString();
     }
 }
index 538d808..9e50549 100644 (file)
@@ -63,6 +63,7 @@ public class TibDoc {
     public static class HTMLWalker extends ReflectiveWalker {
         //public void header() { throw new Error(); }
         public String li(Object o) { return "<li>"+o+"</li>"; }
+        public String li(Object a, Object o) { return "<li>"+o+"</li>"; }
         public String ul(String[] li) { return "<ul>"+join(li,"")+"</ul>"; }
         public String ol(String[] li) { return "<ol>"+join(li,"")+"</ol>"; }
         public String hr() { return "\n<hr/>\n"; }
index dcd7fac..d2c04b1 100644 (file)
@@ -21,5 +21,16 @@ header
   Furthermore, we can try things like
 
     *  this
+    *  this
+    *  this
+      * that
+      * that
+          * these
+      * that
+          1. them
+          #  thar
+          45) dorks
+    *  this
+    *  this
 
-    *  this
\ No newline at end of file
+  this stuff
\ No newline at end of file
index 1df3fb8..a2f5cac 100644 (file)
@@ -37,27 +37,30 @@ kv         ::= word "=" text /ws => kv1
 wp !::= w++
 num !::= [0-9]++
 Paragraph  ::= { "\"\"" ws  text }  => "blockquote"
-             > uli+/ws              => "ul"
-             > { "# "       text }  => "ol"
-             > { num " " ws text }  => "ol"
              > { "---" "-"*      }  => "hr"
              > { text }             => "p"
-uli        ::= { "* " text } => "li"
+
+onums     !::= nums (". "|") ")
+any       !::= ~[]*
+
+uli        ::= "* "         (ws text &~ any (oli|uli)) => "li"
+oli        ::= ("# "|onums) (ws text &~ any (oli|uli)) => "li"
 
 text       ::= Item => text
 Itemx      ::= ws Item
              | ()
 Item       ::= blockquote
-             > pre                       Itemx => []
-             > structured                Itemx => []
-             > structuredx               Itemx => []
-             > styled                    Itemx => []
-             > qtext                     Itemx => []
-             > (alphanum++ => stringify) Itemx => []
-             > symbol                    Itemx => []
-             > (sym++ => stringify)      Itemx => []
-             > Paragraph                       => ""
-             > Paragraph                 Itemx => []
+             > { uli+/ws => "ul" }       Itemx  => []
+             | { oli+/ws => "ol" }       Itemx  => []
+             > pre                       Itemx  => []
+             > structured                Itemx  => []
+             > structuredx               Itemx  => []
+             > styled                    Itemx  => []
+             > qtext                     Itemx  => []
+             > (alphanum++ => stringify) Itemx  => []
+             > symbol                    Itemx  => []
+             > (sym++ => stringify)      Itemx  => []
+             > Paragraph                 Itemx  => []
 
 blockquote ::= "\"\"" text "\"\""        => "blockquote"
              | "\"\"" block              => "blockquote"