X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=bfa176dcc39acadce562a1d2bc406f65f6150711;hp=e85da34cba73511f3ebeda7037509ee96236d785;hb=d75bb01616a13797efda13d752e46a7564e00f41;hpb=ff942a8162f1a5dc4a073448fd89fae7fd0afb14 diff --git a/tests/meta.g b/tests/meta.g index e85da34..bfa176d 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,59 +1,58 @@ -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 - > Es ^"/" E /ws -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" +s ::= !ws 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 + +psy ::= Elements => "ps" + | psy !wp ^"/" !ws e + | psy ^"->" e /ws +Sequence ::= Quoted => "qprod" + > psy => "psx" + | psy ^"=>" ("[]"|"()"|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 + | ^"^" Quoted /ws + + | "(" word ^")" /ws + > ^"(" RHS ")" /ws + | ^"~" e + +word ::= [a-zA-Z0-9_]++ +Quoted ::= "\"" ((~[\"\\] | escaped)+) "\"" + | "\"\"" => "" escaped ::= "\\n" => "\n" | "\\r" => "\r" - | "\\" [~nr] + | "\\" ~[nr] + + +w ::= " " | "\n" | "\r" +ws ::= w** => () + | w** "//" ~[\n]* "\n" ws => () +wp ::= w++