X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=dd222e0fb820f433120e48c0be39db3442a44528;hb=db7344562a20ef098b1f5dc66e8325e55711032c;hp=93a9bb8df6f1d02938128d39ad9ecfd15fb79a69;hpb=927dc9b785de472f2237c5adbc4d2ad12f16cc2d;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 93a9bb8..dd222e0 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,37 +1,34 @@ -s ::= !ws Grammar ws => "gram" -Grammar ::= NonTerminal +/ ws => "grammar" -NonTerminal ::= word ^"::=" RHS /ws +s = !ws Grammar ws => "gram" +Grammar = NonTerminal +/ ws => "grammar" +NonTerminal = word !wp ^"=" !wp RHS + +RHS = (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) -RHS ::= (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) - -Conjuncts ::= Sequence +Conjuncts = Sequence | Sequence ^"&" Elements /ws | Sequence ^"&~" Elements /ws -Elements ::= e*/ws - -ps ::= Elements => "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 ::= ~[\-\]\\] +Elements = e*/ws + +PreSequence = Elements => "ps" + | PreSequence !wp ^"/" !ws e + | PreSequence ^"->" e /ws + | (Quoted|word) ^"::" PreSequence /ws + | PreSequence ^"=>" ("[]"|"()"|word|Quoted) /ws +Sequence = PreSequence => "psx" + +ec = ~[\-\]\\] | escaped -Range ::= ec => "range" +Range = ec => "range" | ec ^"-" ec -e ::= word => "nonTerminal" +e = + (Quoted|word) ^":" e + > word => "nonTerminal" | Quoted => "literal" | ^"()" | ^"{" Sequence "}" /ws | ^"[" Range* "]" - | e ^"++" /ws -> ~[/] | e ^"+" /ws -> ~[+] | e ^"++/" e /ws @@ -42,20 +39,21 @@ e ::= word => "nonTerminal" | e ^"*/" e /ws | ^"!" e /ws | e ^"?" /ws + | ^"^" Quoted /ws | "(" word ^")" /ws > ^"(" RHS ")" /ws | ^"~" e -word ::= [a-zA-Z0-9_]++ -Quoted ::= "\"" ((~[\"\\] | escaped)+) "\"" +word = [a-zA-Z0-9_]++ +Quoted = "\"" ((~[\"\\] | escaped)+) "\"" | "\"\"" => "" -escaped ::= "\\n" => "\n" +escaped = "\\n" => "\n" | "\\r" => "\r" | "\\" ~[nr] -w ::= " " | "\n" | "\r" -ws ::= w** => () +w = " " | "\n" | "\r" +ws = w** => () | w** "//" ~[\n]* "\n" ws => () -wp ::= w++ +wp = w++