X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=c9f53a2701813254feee1d6ed3b73ec45134aaa8;hb=0cbfa6761776083d952b492517ce9f5b866864f5;hp=092cb9ebc5d426f9af5a80d9a5066836091def3f;hpb=6470b3188790f3461508a9f290d70c344c6fedf2;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 092cb9e..c9f53a2 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,67 +1,59 @@ -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**) -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 => "range0" - | ec ^"-" ec => "range1" - -e ::= word => "nonTerminalY" - | [(][)] => "epsilon" - | ^"{" alternatives "}" /ws - | "[" (range*) "]" => "range" - | "[~" (range*) "]" => "rangex" - | 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 +Sequence ::= Quoted => "qprod" + > psy => "psx" + | psy "=>" ^"[]" /ws + | 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++