// WiX Grammar ////////////////////////////////////////////////////////////////////////////// #import url.g as url #import indent.g as indent //#import tokens.g as tokens // disabled until transinclusion bug is fixed s = Doc Doc:: = Header Body Header:: = () // not yet specified Body:: = Section */ br // multi-line header by indenting second line? Section:: = SectionHeader | SectionHeader (nl|br) >> Pars << > SectionHeader (nl|br) Pars SectionHeader:: = (^"=" [=]++) ws (Text & ~[\n]*) Pars:: = (Par <<* & indent.Balanced &~ "=" ...) */ br // An "unbalanced" paragraph (may need trailing outdents to balance) Par = NonTextParagraph > TextParagraph TextParagraph:: = Text NonTextParagraph = UL:: `("":: ("*" BBullet nl)*) "*" UBullet | OL:: `("":: (tok.Int! [.\)]! BBullet nl)*) tok.Int! [.\)]! UBullet | Blockquote:: "\"\"" ws >> Pars | HR:: "---" "-"* | Verbatim:: "\\pre" " "* "\n" (I:: [ ]*) >> Verbatim << // a "balanced bullet" BBullet = (UBullet <<*) & indent.Balanced // an "unbalanced bullet" UBullet = whitespace (LI:: Par */ br) & ~[\n]* ("\n" [ \r\n]* >> ...)? Verbatim = VerbatimBrace:: Verbatim >> Verbatim << | Verbatim:: Verbatim ~[>><<] | Verbatim:: () // note that Text and TextWS are left-recursive because this is more // efficient in LR parsers // text followed by optional whitespace TextWS = () | Text | Text:: `Text (WS:: whitespace) Text:: = `Text nl >> (Pars:: NonTextParagraph) > `TextWS (Link:: Atom "->" ws href) > `TextWS styled > `TextWS Ordinal | `TextWS Fraction > `TextWS Atom | `TextWS (Command:: "\\" ("":: [a-zA-Z0-9:]++ &~ "pre") Block) | `TextWS (Command:: "\\" ("":: [a-zA-Z0-9:]++ &~ "pre") -> ~"{") | `TextWS (Quotes:: "\"" (Text & ~[\"]*) "\"") | `TextWS glyph > `TextWS sym > `Text (WS:: br) >> (Pars -> <<) // subparagraph href = url.Email > url.URL &~ ... url.avoidOnUrlTail > url.Path &~ ... url.avoidOnUrlTail | "{" ws url.Email ws "}" > "{" ws url.URL ws "}" > "{" ws url.Path ws "}" // > Citation:: "[" tok.alphanum++ "]" Atom = Word | Block Block = "{" ws TextWS "}" Word:: = tok.alphanum++ Fraction:: = ("":: [0-9]+) "/" ("":: [0-9]+) Ordinal:: = `("":: [0-9]*) ( [1] "st" | [2] "nd" | [3] "rd" | [04-9] "th" ) styled = Underline:: "__" Text "__" | Footnote:: "((" Text "))" | TT:: "[[" ws (Text & ((~[\]]! | "]" -> ~[\]])*)) ws "]]" | Strikethrough:: "!!" Text "!!" | Superscript:: "^^" Atom | Subscript:: ",," Atom | Bold:: "++" (Text & ((~[\+]! | "+" -> ~[\+])*)) "++" | Highlight:: "##" (Text & ((~[\#]! | "#" -> ~[\#])*)) "##" | Math:: "$$" (~[\$] | ([\$] -> ~[\$]))+ "$$" | Keyword:: "!" Atom | Italic:: "**" (Text & ((~[\*]! | "*" -> ~[\*])*)) "**" glyph = ^"(e)" | ^"(r)" | ^"(c)" | ^"(tm)" | ^"--" | ^"..." | ^"<-" | ^"<=" | ^"=>" | ^"<->" | ^"<=>" | ^"<-" | ^"^o" // ^"->" // Chars /////////////////////////////////////////////////////////////// sym = Word:: "\\" ~tok.alphanum | Word:: ~(tok.alphanum | [\r\n \\{}>><<]) hws! = [ \r>>] ws! = (hws* "\n")? hws* -> ~[ \n\r] whitespace! = hws+ -> ~[ \n\r] | hws* "\n" hws* -> ~[ \n\r] // these don't include indents-as-whitespace nl! = [ \r]* "\n" [ \r]* -> ~[ \n\r] br! = [ \r]* "\n" [ \r]* "\n" [ \r\n]* -> ~[ \n\r]