X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=4c02201f885069539b024d8ad789a290e8297391;hb=475743c156fc5b02e79cd787b3176f5fa1877f83;hp=0920a7a6a5fe8ec1e5f5daae8e92aadf86183613;hpb=0a0227b9180534d2a431f3d6e08a398bde2244c4;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 0920a7a..cc33104 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,54 +1,57 @@ -s ::= w* Grammar w* => "gram" -Grammar ::= R+ => "grammar" -R ::= word ^"::=" Class+/gt - | word ^"!::=" Class+/gt - -ec ::= [~\]\\\-\~] | escaped - -Class ::= Rewrite +/ bar => "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 = ws gram:Grammar ws +Grammar = grammar:: NonTerminal +/ ws +NonTerminal = word !wp ^"=" !wp RHS + +RHS = (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws) + +Elements = e*/ws + +PreSequence = ps:: Elements + | PreSequence !wp ^"/" !ws e + | PreSequence ^"->" e /ws + | (Quoted|word) ^"::" PreSequence /ws + +Sequence = psx:: PreSequence + | Sequence !ws ^"&" !ws Elements + | Sequence !ws ^"&~" !ws Elements + +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 + | "(" word ^")" /ws + > ^"(" RHS ")" /ws + | ^"~" e + > "^^":: "^" 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++