X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=64f18f928cbfeff94633f38e1245cd963acafacd;hp=4c02201f885069539b024d8ad789a290e8297391;hb=50ff66e926f981a5b3716f218ad24603c2a12e3f;hpb=548a4a1afc3c2f2a521f0b564925aa92adfbe557 diff --git a/tests/meta.g b/tests/meta.g index 4c02201..64f18f9 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,53 +1,53 @@ -s ::= w* Grammar w* => "gram" -Grammar ::= R+ => "grammar" -R ::= word ^"::=" Sequence - | word ^"!::=" Sequence - -ec ::= [~\]\\\-\~] | escaped - -Sequence ::= Class +/ ">" -Class ::= Rewrite +/ "|" => "alternatives" - -Rewrite ::= Rewritex - | Rewritex ^"&" E+ - | Rewritex ^"&~" E+ - -Rewritex ::= E+ => "rewrite" - | E+ ^"=>" word - | E+ ^"=>" quoted - | E+ "=>" "()" => "wrap" - -range ::= ec => "range0" | ec ^"-" ec => "range0" -E ::= word => "nonTerminalY" - | [(][)] => "epsilon" - | ^"{" Sequence "}" - | "[" [\~]? 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 ::= (conjuncts +/ (ws "|" ws)) +/ (ws ">" ws) + +conjuncts ::= sequence + | sequence ^"&" e*/ws /ws + | sequence ^"&~" e*/ws /ws - | (E ^"**" > E ^"*") - | (E ^"++" > E ^"+") +ps ::= e*/ws => "ps" + | (e+/ws ws)? "^" quoted (ws e+/ws)? => "ps2" +psx ::= ps + > ps ^"/" e /ws +sequence ::= psx + | psx ^"=>" (word|quoted) /ws - | "(" word ^")" - > ^"(" Sequence ")" +ec ::= [~\-\]\\\~] + | escaped +range ::= ec => "range" + | ec ^"-" ec + +e ::= word => "nonTerminal" + | quoted => "literal" + | ^"()" + | ^"{" sequence "}" /ws + | ^"[" range* "]" + | ^"[~" range* "]" + + | (e ws ^"**" > e ws ^"*") + | e ^"*/" e /ws + | (e ws ^"++" > e ws ^"+") + | e ^"+/" e /ws + | e ^"?" /ws + + | "(" word ^")" /ws + > ^"(" alternatives ")" /ws w !::= " " - | "//" [~\n]* "\n" + | "//" ([~\n]*) "\n" | "\n" | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ => "sify" -quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify" +word ::= [a-zA-Z0-9_]++ +quoted ::= "\"" (([~\"\\] | escaped)+) "\"" + | "\"\"" => "" escaped ::= "\\n" => "\n" | "\\r" => "\r" | "\\" [~nr] + +