+// use 'a'-'z' or 'a-z' instead of [a-z]?
+// EOF token?
+// #include (with renaming?)
+// ANTLR uses ! and ^ suffixes
+
+s = ws grammar:Grammar ws
+Grammar = NonTerminal +/ ws
+NonTerminal = Word ^"=" RHS /ws
+
+RHS = (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws)
+
+Elements = e*/ws
+
+PreSequence = ps:: Elements
+ | (Quoted|Word) ^"::" PreSequence /ws
+ > PreSequence ^"/" e /ws
+ | PreSequence ^"->" e /ws
+
+Sequence = psx:: PreSequence
+ | Sequence ^"&" Elements /ws
+ | Sequence ^"&~" Elements /ws
+
+ec = ~[\-\]\\]
+ | escaped
+
+Range = range:: ec
+ | ec ^"-" ec
+
+e = (Quoted|Word) ^":" e
+ > nonTerminal:: Word
+ | literal:: Quoted
+ | ^"()"
+ | ^"{" PreSequence "}" /ws
+ | ^"[" Range* "]"
+ | e ^"++" /ws -> ~[/]
+ | e ^"+" /ws -> ~[+]
+ | e ^"++/" e /ws
+ | e ^"+/" e /ws
+ | e ^"**" /ws -> ~[/]
+ | e ^"*" /ws -> ~[*]
+ | e ^"**/" e /ws
+ | e ^"*/" e /ws
+ | ^"!" e /ws
+ | e ^"?" /ws
+ | ^"^" Quoted
+ | "(" Word ^")" /ws
+ > ^"(" RHS ")" /ws
+ | ^"~" e
+ > "^^":: "^" e
+
+Word = [a-zA-Z0-9_]++
+Quoted = "\"" ((~[\"\\] | escaped)+) "\""
+ | "":: "\"\""
+escaped = "\n":: "\\n"
+ | "\r":: "\\r"
+ | "\\" ~[nr]
+
+w = " " | "\n" | "\r"
+ws = "()":: w**
+ | "()":: w** "//" ~[\n]* "\n" ws
+wp = w++