X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=43f539a77a4f0c4229a75a5cf9b6bdd3cb0ddede;hp=019d5e37ce7a96ea2a99d5bbf97d8086f3ce7357;hb=86e7e1298601b60df964e3c0a71f3fe3cca230b8;hpb=025ebe3e707adc361fbfbae9ea6120699f5d045a diff --git a/tests/meta.g b/tests/meta.g index 019d5e3..43f539a 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,35 +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 - -psy ::= Elements => "ps" - | Elements !wp "/" !ws e => "ps2" -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 @@ -40,21 +39,21 @@ e ::= word => "nonTerminal" | e ^"*/" e /ws | ^"!" e /ws | e ^"?" /ws - | "^" Quoted /ws => caret + | ^"^" 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++