1 // WiX Grammar //////////////////////////////////////////////////////////////////////////////
4 #import indent.g as indent
6 //#import tokens.g as tokens // disabled until transinclusion bug is fixed
11 Header:: = () // not yet specified
12 Body:: = Section */ br
14 // multi-line header by indenting second line?
15 Section:: = SectionHeader
16 | SectionHeader (nl|br) >> Pars <<
17 > SectionHeader (nl|br) Pars
18 SectionHeader:: = (^"=" [=]++) ws (Text & ~[\n]*)
20 Pars:: = (Par <<* & indent.Balanced &~ "=" ...) */ br
22 // An "unbalanced" paragraph (may need trailing outdents to balance)
23 Par = NonTextParagraph
26 TextParagraph:: = Text
28 NonTextParagraph = UL:: `("":: ("*" BBullet nl)*) "*" UBullet
29 | OL:: `("":: (tok.Int! [.\)]! BBullet nl)*) tok.Int! [.\)]! UBullet
30 | Blockquote:: "\"\"" ws >> Pars
32 | Verbatim:: "\\pre" " "* "\n" (I:: [ ]*) >> Verbatim <<
34 // a "balanced bullet"
35 BBullet = (UBullet <<*) & indent.Balanced
37 // an "unbalanced bullet"
38 UBullet = whitespace (LI:: Par */ br)
39 & ~[\n]* ("\n" [ \r\n]* >> ...)?
41 Verbatim = VerbatimBrace:: Verbatim >> Verbatim <<
42 | Verbatim:: Verbatim ~[>><<]
45 // note that Text and TextWS are left-recursive because this is more
46 // efficient in LR parsers
48 // text followed by optional whitespace
51 | Text:: `Text (WS:: whitespace)
53 Text:: = `Text nl >> (Pars:: NonTextParagraph)
54 > `TextWS (Link:: Atom "->" ws href)
59 | `TextWS (Command:: "\\" ("":: [a-zA-Z0-9:]++ &~ "pre") Block)
60 | `TextWS (Command:: "\\" ("":: [a-zA-Z0-9:]++ &~ "pre") -> ~"{")
61 | `TextWS (Quotes:: "\"" (Text & ~[\"]*) "\"")
64 > `Text (WS:: br) >> (Pars -> <<) // subparagraph
67 > url.URL &~ ... url.avoidOnUrlTail
68 > url.Path &~ ... url.avoidOnUrlTail
69 | "{" ws url.Email ws "}"
70 > "{" ws url.URL ws "}"
71 > "{" ws url.Path ws "}"
72 // > Citation:: "[" tok.alphanum++ "]"
75 Block = "{" ws TextWS "}"
76 Word:: = tok.alphanum++
77 Fraction:: = ("":: [0-9]+) "/" ("":: [0-9]+)
78 Ordinal:: = `("":: [0-9]*) ( [1] "st"
83 styled = Underline:: "__" Text "__"
84 | Footnote:: "((" Text "))"
85 | TT:: "[[" ws (Text & ((~[\]]! | "]" -> ~[\]])*)) ws "]]"
86 | Strikethrough:: "!!" Text "!!"
87 | Superscript:: "^^" Atom
88 | Subscript:: ",," Atom
89 | Bold:: "++" (Text & ((~[\+]! | "+" -> ~[\+])*)) "++"
90 | Highlight:: "##" (Text & ((~[\#]! | "#" -> ~[\#])*)) "##"
91 | Math:: "$$" (~[\$] | ([\$] -> ~[\$]))+ "$$"
93 | Italic:: "**" (Text & ((~[\*]! | "*" -> ~[\*])*)) "**"
95 glyph = ^"(e)" | ^"(r)" | ^"(c)" | ^"(tm)" | ^"--"
96 | ^"..." | ^"<-" | ^"<=" | ^"=>" | ^"<->"
97 | ^"<=>" | ^"<-" | ^"^o"
103 // Chars ///////////////////////////////////////////////////////////////
105 sym = Word:: "\\" ~tok.alphanum
106 | Word:: ~(tok.alphanum | [\r\n \\{}>><<])
109 ws! = (hws* "\n")? hws* -> ~[ \n\r]
110 whitespace! = hws+ -> ~[ \n\r]
111 | hws* "\n" hws* -> ~[ \n\r]
113 // these don't include indents-as-whitespace
114 nl! = [ \r]* "\n" [ \r]* -> ~[ \n\r]
115 br! = [ \r]* "\n" [ \r]* "\n" [ \r\n]* -> ~[ \n\r]