/** 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();
}
}
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"; }
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
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"