X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=a540d78e7ab107f058b819b7c567c1a3eb379989;hp=1dccbd60d29a352a2ec5bd60a8855135619b787d;hb=b14c82d2c557d38194abc5b0ebbacc87e880b709;hpb=ea5d0a5e3dffb5ba0143179fd28608c2de8046e0 diff --git a/tests/meta.g b/tests/meta.g index 1dccbd6..a540d78 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,54 +1,58 @@ -s ::= w* Grammar w* => "gram" -Grammar ::= R+ => "grammar" -R ::= word ^"::=" Class+/gt - | word ^"!::=" Class+/gt - -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" -gt !::= ">" -bar !::= "|" -E ::= word => "nonTerminalY" - | [(][)] => "epsilon" - | ^"{" Class+/gt "}" - | "[" [\~]? range* "]" => "range" - | E ^"*/" E - | E ^"+/" E - | E ^"?" - | E ^"~/~" - - | E ^"-" E - - | ^"!" E - | "^" quoted => "care" - | ^"`" E - | E ^"#" - | quoted => "literal" - - | (E ^"**" > E ^"*") - | (E ^"++" > E ^"+") - - | "(" word ^")" - > ^"(" Class+/gt ")" - -w !::= " " - | "//" [~\n]* "\n" - | "\n" - | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ => "sify" -quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify" -escaped ::= "\\n" => "\n" - | "\\r" => "\r" - | "\\" [~nr] +s = gram:: !ws Grammar ws +Grammar = grammar:: NonTerminal +/ ws +NonTerminal = word !wp ^"=" !wp RHS + +RHS = (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) + +Conjuncts = Sequence + | Sequence ^"&" Elements /ws + | Sequence ^"&~" Elements /ws +Elements = e*/ws + +PreSequence = ps:: Elements + | PreSequence !wp ^"/" !ws e + | PreSequence ^"->" e /ws + | (Quoted|word) ^"::" PreSequence /ws + | PreSequence ^"=>" ("[]"|"()"|word|Quoted) /ws +Sequence = psx:: PreSequence + +ec = ~[\-\]\\] + | escaped + +Range = range:: ec + | ec ^"-" ec + +e = (Quoted|word) ^":" e + > nonTerminal:: word + | literal:: Quoted + | ^"()" + | ^"{" 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] + + +w = " " | "\n" | "\r" +ws = "()":: w** + | "()":: w** "//" ~[\n]* "\n" ws +wp = w++