Doc ::= {Header} Body /ws => doc
Header ::= "header" { kv */ ws } /ws => header
-Body ::= Section*/ws => body
+Body ::= Section*/ws => body
Section ::= { SectionHeader Paragraph* /ws => section }
SectionHeader ::= "==" SectionHeaderBody "=="
SectionHeaderBody ::= "=" SectionHeaderBody "="
blank ::= sp "\n" sp "\n" ws
kv ::= word "=" text /ws => kv1
-
+wp !::= w++
num !::= [0-9]++
-Paragraph ::= { "\"\"" ws text } => "blockquote"
- > { "*" " " ws text } => "ul"
- > { "#" " " ws text } => "ol"
+Paragraph ::= { "\"\"" ws text } => "blockquote"
+ > uli+/ws => "ul"
+ > { "# " text } => "ol"
> { num " " ws text } => "ol"
> { "---" "-"* } => "hr"
> { text } => "p"
-
-text ::= item
-itemx ::= ws item | ()
-item ::= blockquote
- > pre itemx => []
- > structured itemx => []
- > structuredx itemx => []
- > styled itemx => []
- > qtext itemx => []
- > alphanum++ itemx => []
- > symbol itemx => []
-// > sym++ itemx => []
- > Paragraph itemx => []
-
-symbol ::= sym++
+uli ::= { "* " text } => "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 => []
blockquote ::= "\"\"" text "\"\"" => "blockquote"
| "\"\"" block => "blockquote"
qtext ::= "\"" text "\"" => "quoted"
pre ::= "[verbatim]" { ~[]+ } /ws => "verbatim" // FIXME doesn't work
-styled ::= "__" text "__" => ul
+styled ::= "__" text "__" => underline
| "((" text "))" => footnote
- | ( "[[" text "]]" => tt
- > "[" word "]" => citation
+ | ( "[[" text "]]" => tt
+ > "[" word "]" => citation
)
| "!!" text "!!" => strikethrough
| "^^" (word|block) => superscript
// only gets parsed once
urlpath ::= urlchar*
-username ::= [a-zA-Z0-9;/?:&=$\-_.+]++
-password ::= [a-zA-Z0-9;/?:&=$\-_.+]++
+username ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => stringify
+password ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => stringify
urlchar ::= [a-zA-Z0-9;/?:&=$\-_.+@]
| "%" [0-9] [0-9] => "%"
url ::= "mailto" ":" email
- > method "://" url_login? host (":" port)? ("/" urlpath)? => "url"
-url_login ::= username (":" password) "@" => "login"
-method ::= [+\-.a-z0-9]+
-port ::= [0-9]+
-
-domain ::= (part +/ ".") -> ~"."
-part ::= [a-zA-Z0-9\-]++ // interesting use of boolean grammars
+ > method "://" url_login? host (":" nums)? ("/" urlpath)? => "url"
+url_login ::= username (":" password) "@" => "login"
+method ::= [+\-.a-z0-9]+ => stringify
+domain ::= (part +/ ".") -> ~"." => domain
+part ::= [a-zA-Z0-9\-]++ => stringify
+// interesting use of boolean grammars
// &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
email ::= username "@" host -> ~[.] => emailaddr
-host ::= [0-9]+ "." [0-9]+ "." [0-9]+ "." [0-9]+ => "ip"
+nums ::= [0-9]++ => stringify
+host ::= nums "." nums "." nums "." nums => "ip"
| domain
// Tokens ///////////////////////////////////////////////////////////////////
-word ::= alphanum++
+word ::= alphanum++ => stringify
| quoted
quoted ::= "\"" ((~[\"\\] | escaped)+) "\""