X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=c9f53a2701813254feee1d6ed3b73ec45134aaa8;hb=0cbfa6761776083d952b492517ce9f5b866864f5;hp=2f062c4fdf4e97403dff529be44ba41d7ed0f553;hpb=a19f44a6cc6e3a2b0c2f3dadd7be2263d6ff0c3e;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 2f062c4..c9f53a2 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,54 +1,59 @@ -s ::= ws grammar ws => "gram" -ws !::= w** -grammar ::= r +/ ws => "grammar" -r ::= word ^"::=" alternatives /ws - | word ^"!::=" alternatives /ws - -alternatives ::= (conjuncts +/ (ws "|" ws)) +/ (ws ">" ws) - -conjuncts ::= sequence - | sequence ^"&" e*/ws /ws - | sequence ^"&~" e*/ws /ws - -ps ::= e*/ws => "ps" -psx ::= ps - > ps ^"/" e /ws -sequence ::= psx - | psx ^"=>" (word|quoted) /ws - -ec ::= [~\-\]\\\~] - | escaped - -range ::= ec => "range" - | ec ^"-" ec - -e ::= word => "nonTerminal" - | quoted => "literal" - | ^"()" - | ^"{" sequence "}" /ws - | ^"[" range* "]" - | ^"[~" range* "]" - | ^"^" quoted /ws -// | ^"!" e /ws - - | (e ws ^"**" > e ws ^"*") - | e ^"*/" e /ws - | (e ws ^"++" > e ws ^"+") - | e ^"+/" e /ws - | e ^"?" /ws - - | "(" word ^")" /ws - > ^"(" alternatives ")" /ws - -w !::= " " - | "//" ([~\n]*) "\n" - | "\n" - | "\r" +s ::= !ws Grammar ws => "gram" +Grammar ::= NonTerminal +/ ws => "grammar" +NonTerminal ::= word ^"::=" RHS /ws + +RHS ::= (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) + +Conjuncts ::= Sequence + | Sequence ^"&" Elements /ws + | Sequence ^"&~" Elements /ws +Elements ::= e*/ws + +psy ::= Elements => "ps" + | psy !wp ^"/" !ws e + | psy ^"->" e /ws +Sequence ::= Quoted => "qprod" + > psy => "psx" + | psy "=>" ^"[]" /ws + | psy ^"=>" ("()"|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 + | ^"^" Quoted /ws + + | "(" word ^")" /ws + > ^"(" RHS ")" /ws + | ^"~" e + word ::= [a-zA-Z0-9_]++ -quoted ::= "\"" (([~\"\\] | escaped)+) "\"" +Quoted ::= "\"" ((~[\"\\] | escaped)+) "\"" | "\"\"" => "" escaped ::= "\\n" => "\n" | "\\r" => "\r" - | "\\" [~nr] + | "\\" ~[nr] +w ::= " " | "\n" | "\r" +ws ::= w** => () + | w** "//" ~[\n]* "\n" ws => () +wp ::= w++