X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=cc33104b4536e4385dc2f0cc984f988186b1c64e;hp=b1fb352417b934725976b9d64399d4255b61a0c8;hb=475743c156fc5b02e79cd787b3176f5fa1877f83;hpb=2244708b6521e2ee6ac89e24887119abda93da3a diff --git a/tests/meta.g b/tests/meta.g index b1fb352..cc33104 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,61 +1,57 @@ -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] - - +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++