X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=dd222e0fb820f433120e48c0be39db3442a44528;hb=db7344562a20ef098b1f5dc66e8325e55711032c;hp=31397949a77b10efdcf15e5b5b02685a607bd407;hpb=8ac1795e6098dcf10b94a854351162695181b83d;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 3139794..dd222e0 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,33 +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 +Elements = e*/ws -psy ::= Elements => "ps" - | psy !wp ^"/" !ws e - | psy ^"->" e /ws - | psy ^"=>" ("[]"|"()"|word|Quoted) /ws -Sequence ::= Quoted => "qprod" - > psy => "psx" +PreSequence = Elements => "ps" + | PreSequence !wp ^"/" !ws e + | PreSequence ^"->" e /ws + | (Quoted|word) ^"::" PreSequence /ws + | PreSequence ^"=>" ("[]"|"()"|word|Quoted) /ws +Sequence = PreSequence => "psx" -ec ::= ~[\-\]\\] +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 @@ -44,15 +45,15 @@ e ::= word => "nonTerminal" > ^"(" 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++