-s ::= w* Grammar w* => "gram"
-Grammar ::= R+ => "grammar"
-R ::= word ^"::=" Class+/gt
- | word ^"!::=" Class+/gt
-
-ec ::= [~\]\\\-\~] | escaped
-
-Class ::= Rewrite +/ bar => "alternatives"
-
-Rewrite ::= Rewritex
- | Rewritex ^"&" E+
- | Rewritex ^"&~" E+
-
-Rewritex ::= E+ => "rewrite"
- | E+ ^"=>" word
- | E+ ^"=>" quoted
- | E+ "=>" "()" => "wrap"
-
-range ::= ec => "range0" | ec ^"-" ec => "range0"
-gt !::= ">"
-bar !::= "|"
-E ::= word => "nonTerminalY"
- | [(][)] => "epsilon"
- | ^"{" Class+/gt "}"
- | "[" [\~]? range* "]" => "range"
- | E ^"*/" E
- | E ^"+/" E
- | E ^"?"
- | E ^"~/~"
-
- | E ^"-" E
-
- | ^"!" E
- | "^" quoted => "care"
- | ^"`" E
- | E ^"#"
- | quoted => "literal"
+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)
+
+sequence ::= es
+ > es ws ^"/" e
+es ::= e */ (w**)
+
+ss ::= es | es ^"/" e /ws
+
+conjuncts ::= rewrite
+ | rewrite ^"&" e*/ws /ws
+ | rewrite ^"&~" e*/ws /ws
+
+rewrite ::= sequence /ws => "rewrite"
+ | sequence ^"=>" word /ws
+ | sequence ^"=>" quoted /ws
+
+ec ::= [~\-\]\\\~]
+ | escaped
- | (E ^"**" > E ^"*")
- | (E ^"++" > E ^"+")
+range ::= ec => "range"
+ | ec ^"-" ec
- | "(" word ^")"
- > ^"(" Class+/gt ")"
+e ::= word => "nonTerminal"
+ | [(][)] => "epsilon"
+ | ^"{" alternatives "}" /ws
+ | ^"[" (range*) "]"
+ | ^"[~" (range*) "]"
+ | ^"^" quoted /ws
+ | e ^"~/~" /ws
+ | ^"!" e /ws
+
+ | ^"`" e /ws
+ | e ^"#" /ws
+
+ | (e ws ^"**" > e ws ^"*")
+ | e ^"*/" e /ws
+ | (e ws ^"++" > e ws ^"+")
+ | e ^"+/" e /ws
+ | e ^"?" /ws
+
+ | quoted => "literal"
+
+ | "(" word ^")" /ws
+ > ^"(" alternatives ")" /ws
w !::= " "
- | "//" [~\n]* "\n"
+ | "//" ([~\n]*) "\n"
| "\n"
| "\r"
an ::= [a-zA-Z0-9_]
-word ::= an++ => "sify"
-quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify"
+word ::= an++
+quoted ::= "\"" (([~\"\\] | escaped)+) "\""
+ | "\"\"" => ""
escaped ::= "\\n" => "\n"
| "\\r" => "\r"
| "\\" [~nr]
+
+