-s ::= w* Grammar w* => "gram"
-ws !::= w*
-grammar ::= R+/ws => "grammar"
-Grammar ::= R+ => "grammar"
-R ::= word ^"::=" Alternatives
- | word ^"!::=" Alternatives
-
-ec ::= [~\]\\\-\~] | escaped
-
-Alternatives ::= EquiAlt +/ ">"
-EquiAlt ::= Conjuncts +/ "|" => "alternatives"
-
-Sequence ::= E+ ^"/" E
- > E+
-
-Conjuncts ::= rewrite
- | rewrite ^"&" Sequence
- | rewrite ^"&~" Sequence
-
-rewrite ::= Sequence /ws => "rewrite"
- | Sequence ^"=>" word /ws
- | Sequence ^"=>" quoted /ws
- | Sequence "=>" "()" /ws => "wrap"
-
-range ::= ec => "range0" | ec ^"-" ec => "range0"
-E ::= word => "nonTerminalY"
- | [(][)] => "epsilon"
- | ^"{" Alternatives "}"
- | "[" [\~]? range* "]" => "range"
- | E ^"*/" E
- | E ^"+/" E
- | E ^"?"
- | E ^"~/~"
-
- | E ^"-" E
-
- | ^"!" E
- | "^" quoted => "care"
- | ^"`" E
- | E ^"#"
- | quoted => "literal"
-
- | (E ^"**" > E ^"*")
- | (E ^"++" > E ^"+")
-
- | "(" word ^")"
- > ^"(" Alternatives ")"
-
-w !::= " "
- | "//" [~\n]* "\n"
- | "\n"
- | "\r"
-an ::= [a-zA-Z0-9_]
-word ::= an++ => "sify"
-quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify"
+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
+
+word ::= [a-zA-Z0-9_]++
+Quoted ::= "\"" ((~[\"\\] | escaped)+) "\""
+ | "\"\"" => ""