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 ::= Es ^"/" E /ws > Es Es ::= 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" escaped ::= "\\n" => "\n" | "\\r" => "\r" | "\\" [~nr]