X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=e7f3524397dc615bd5b252fc60b08f836879e076;hb=d824fe4034e79260f1f065d1040a39571897cd95;hp=55bc02af5668533b149de1ee805deae3a024a560;hpb=b194da7e8cc5bd13e03d59008c34deefc4e15764;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 55bc02a..e7f3524 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,59 +1,58 @@ -s ::= ws grammar ws => "gram" -ws !::= w** -grammar ::= r+/ws => "grammar" -r ::= word ^"::=" alternatives /ws - | word ^"!::=" alternatives /ws - -ec ::= [~\]\\\-\~] | escaped - -alternatives ::= equiAlt +/ (ws ">" ws) -equiAlt ::= conjuncts +/ (ws "|" ws) => "alternatives" - -sequence ::= Es - > Es ^"/" e /ws -Es ::= e+ -//es ::= E+/ws - -conjuncts ::= rewrite - | rewrite ^"&" sequence /ws - | rewrite ^"&~" sequence /ws - -rewrite ::= sequence /ws => "rewrite" - | sequence ^"=>" word /ws - | sequence ^"=>" quoted /ws - | sequence "=>" "()" /ws => "wrap" - -range ::= ec => "range0" | ec ^"-" ec => "range0" -e ::= word => "nonTerminalY" - | [(][)] => "epsilon" - | ^"{" alternatives "}" /ws - | "[" [\~]? range* "]" => "range" - | e ^"*/" e /ws - | e ^"+/" e /ws - | e ^"?" /ws - | e ^"~/~" /ws - - | e ^"-" e /ws - - | ^"!" e /ws - | "^" quoted /ws => "care" - | ^"`" e /ws - | e ^"#" /ws - | quoted => "literal" - - | (e ws ^"**" > e ws ^"*") - | (e ws ^"++" > e ws ^"+") - - | "(" word ^")" /ws - > ^"(" alternatives ")" /ws - -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 + | psy "=>" ("[]"|"()"|word|Quoted) /ws => goo +Sequence ::= Quoted => "qprod" + > psy => "psx" + +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++