-s ::= ws grammar ws => "gram"
-ws !::= w**
-grammar ::= r +/ ws => "grammar"
-r ::= word ^"::=" alternatives /ws
- | word ^"!::=" alternatives /ws
-
-alternatives ::= equiAlt +/ (ws ">" ws)
-equiAlt ::= conjuncts +/ (ws "|" ws)
-
-conjuncts ::= sequence
- | sequence ^"&" e*/ws /ws
- | sequence ^"&~" e*/ws /ws
-
-sequence ::= e*/ws
- (ws "/" e)?
- (ws "=>" ws (word|quoted))? => "seq"
-
-ec ::= [~\-\]\\\~]
- | escaped
-
-range ::= ec => "range"
- | ec ^"-" ec
-
-e ::= word => "nonTerminal"
- | quoted => "literal"
- | ^"()"
- | ^"{" sequence "}" /ws
- | ^"[" (range*) "]"
- | ^"[~" (range*) "]"
- | ^"^" quoted /ws
- | ^"!" e /ws
-
- | (e ws ^"**" > e ws ^"*")
- | e ^"*/" e /ws
- | (e ws ^"++" > e ws ^"+")
- | e ^"+/" e /ws
- | e ^"?" /ws
-
- | "(" word ^")" /ws
- > ^"(" alternatives ")" /ws
-
-w !::= " "
- | "//" ([~\n]*) "\n"
- | "\n"
- | "\r"
+s ::= Grammar ws => "gram"
+Grammar ::= NonTerminal +/ ws => "grammar"
+NonTerminal ::= word ^"::=" RHS /ws
+
+RHS ::= (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws)
+
+Conjuncts ::= Sequence
+ | Sequence ^"&" Elements /ws
+ | Sequence ^"&~" Elements /ws
+Elements ::= e*/ws
+
+ps ::= Elements => "ps"
+ | (e+/ws !ws)? ^"^" Quoted (!ws e+/ws)?
+psy ::= ps
+ | ps !wp ^"/" !ws e
+psx ::= psy => "psy"
+ | psy ^"->" e /ws
+Sequence ::= Quoted => "qprod"
+ > psx => "psx"
+ | psx "=>" ^"[]" /ws
+ | psx ^"=>" ("()"|word|Quoted) /ws
+
+ec ::= ~[\-\]\\]
+ | escaped
+
+Range ::= ec => "range"
+ | ec ^"-" ec
+
+e ::= word => "nonTerminal"
+ | Quoted => "literal"
+ | ^"()"
+ | ^"{" Sequence "}" /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
+
+ | "(" word ^")" /ws
+ > ^"(" RHS ")" /ws
+ | ^"~" e
+