X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Ftibdoc.g;h=a2f5cacac3fad3e838888e932aad54ee3c5fd85b;hb=50ee1870e1323d1b0b790fd4fc46d6845930bced;hp=e77d53b7314829e60f82a2105e9e5fb85ad4f736;hpb=83b94810a384ee3b579cc83c51f26dc7100e25b8;p=sbp.git diff --git a/tests/tibdoc.g b/tests/tibdoc.g index e77d53b..a2f5cac 100644 --- a/tests/tibdoc.g +++ b/tests/tibdoc.g @@ -24,7 +24,7 @@ s ::= Doc => top 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 "=" @@ -34,29 +34,33 @@ sp !::= " "** 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" - > { num " " ws text } => "ol" +Paragraph ::= { "\"\"" ws text } => "blockquote" > { "---" "-"* } => "hr" > { text } => "p" -text ::= Item -Itemx ::= ws Item | () +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++ Itemx => [] - > Paragraph Itemx => [] - -symbol ::= sym++ + > { 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" @@ -64,7 +68,7 @@ blockquote ::= "\"\"" text "\"\"" => "blockquote" qtext ::= "\"" text "\"" => "quoted" pre ::= "[verbatim]" { ~[]+ } /ws => "verbatim" // FIXME doesn't work -styled ::= "__" text "__" => ul +styled ::= "__" text "__" => underline | "((" text "))" => footnote | ( "[[" text "]]" => tt > "[" word "]" => citation @@ -95,22 +99,22 @@ glyph ::= "(r)" | "(c)" | "(tm)" | "--" // euro symbol? // 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