X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=e7f3524397dc615bd5b252fc60b08f836879e076;hb=d824fe4034e79260f1f065d1040a39571897cd95;hp=975e855f07036faaa6c1bdf489a34e03082aaba8;hpb=202da2dfa080e426c29c14123b3f2485b53f12dd;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 975e855..e7f3524 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,66 +1,58 @@ -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) => "alternatives" - -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 - | sequence "=>" "()" /ws => "wrap" - -ec ::= [~\-\]\\\~] - | escaped - -range ::= ec => "range" - | ec ^"-" ec - -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++