X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=349be330fb6f69577a6aee8ce71ed8fd7c5113b9;hb=e94712936f420a315c2a1db2c2e9e838c58a35cc;hp=beda61b07978b082fffb17a3fa3c0d06a427b4ac;hpb=1981ad8a9fea8bf4d0940b649c211741b17dd1ff;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index beda61b..349be33 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,52 +1,61 @@ -s ::= w* Grammar w* => "gram" -Grammar ::= R+ => "grammar" -R ::= word ^"::=" Class+/">" - | word ^"!::=" Class+/">" - -ec ::= [~\]\\\-\~] | escaped - -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" - | ^"{" Class+/">" "}" - | "[" [\~]? range* "]" => "range" - | E ^"*/" E - | E ^"+/" E - | E ^"?" - | E ^"~/~" - - | E ^"-" E - - | ^"!" E - | "^" quoted => "care" - | ^"`" E - | E ^"#" - | quoted => "literal" - - | (E ^"**" > E ^"*") - | (E ^"++" > E ^"+") - - | "(" word ^")" - > ^"(" Class+/">" ")" - -w !::= " " - | "//" [~\n]* "\n" - | "\n" - | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ => "sify" -quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify" +s ::= Grammar ws => "gram" +Grammar ::= NonTerminal +/ ws => "grammar" +NonTerminal ::= word ^"::=" RHS /ws + +w ::= " " | "\n" | "\r" +ws ::= w** => () + | w** "//" ~[\n]* "\n" ws => () +wp ::= w++ + +RHS ::= (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) + +Conjuncts ::= Sequence + | Sequence ^"&" e*/ws /ws + | Sequence ^"&~" e*/ws /ws + +ps ::= e*/ws => "ps" + | (e+/ws !ws)? ^"^" Quoted (!ws e+/ws)? +psy ::= ps + | ps !wp ^"/" !ws e +psx ::= psy => "psy" + | psy ^"->" e /ws +Sequence ::= Quoted => "qprod" + > psx => "psx" + | psx "=>" ^"[]" /ws + | psx ^"=>" ("()"|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 + + | "(" word ^")" /ws + > ^"(" RHS ")" /ws + | ^"~" e + +word ::= [a-zA-Z0-9_]++ +Quoted ::= "\"" ((~[\"\\] | escaped)+) "\"" + | "\"\"" => "" escaped ::= "\\n" => "\n" | "\\r" => "\r" - | "\\" [~nr] + | "\\" ~[nr] + +