X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Ftibdoc.g;h=a2f5cacac3fad3e838888e932aad54ee3c5fd85b;hb=8ac1795e6098dcf10b94a854351162695181b83d;hp=38104af6e63207de89d49b8c275fc076bf046ee5;hpb=9ded11559a1b6f817e99355b1c9e2c88042e91d4;p=sbp.git diff --git a/tests/tibdoc.g b/tests/tibdoc.g index 38104af..a2f5cac 100644 --- a/tests/tibdoc.g +++ b/tests/tibdoc.g @@ -20,40 +20,47 @@ nw ::= ~[\r\n\ ] ////////////////////////////////////////////////////////////////////////////// -s ::= {Doc} => top +s ::= Doc => top -Doc ::= Header Body /ws => doc -Header ::= "header" { kv */ ws } /ws => header -Body ::= Section*/ws => body -Section ::= SectionHeader Paragraph*/ws /ws => section +Doc ::= {Header} Body /ws => doc +Header ::= "header" { kv */ ws } /ws => header +Body ::= Section*/ws => body +Section ::= { SectionHeader Paragraph* /ws => section } SectionHeader ::= "==" SectionHeaderBody "==" SectionHeaderBody ::= "=" SectionHeaderBody "=" > ws text ws -kv ::= word "=" text /ws => kv1 +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" - > { "---" "-"* } => "hr" - > { text } => "p" - -text ::= item => "t" -itemx ::= ws item => "w" | () -item ::= blockquote => "b" - > pre itemx => "a" - > structured itemx => "1" - > structuredx itemx => "2" - > styled itemx => "3" - > qtext itemx => "4" - > alphanum++ itemx => "5" - > symbol itemx => "6" -// > sym++ itemx => [] - > Paragraph itemx => "7" - -symbol ::= sym++ +Paragraph ::= { "\"\"" ws text } => "blockquote" + > { "---" "-"* } => "hr" + > { text } => "p" + +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 + > { 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" @@ -61,10 +68,10 @@ 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 + | ( "[[" text "]]" => tt + > "[" word "]" => citation ) | "!!" text "!!" => strikethrough | "^^" (word|block) => superscript @@ -75,7 +82,7 @@ styled ::= "__" text "__" => ul > "*" text "*" => it block ::= { text } -structured ::= { text } "->" (url|email) => link +structured ::= { text } "->" (url|email) => link //> alphanum++ "->" (url|email) => link structuredx ::= glyph > email @@ -92,29 +99,29 @@ 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 // Tokens /////////////////////////////////////////////////////////////////// -word ::= alphanum++ +word ::= alphanum++ => stringify | quoted quoted ::= "\"" ((~[\"\\] | escaped)+) "\""