X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=93a9bb8df6f1d02938128d39ad9ecfd15fb79a69;hb=927dc9b785de472f2237c5adbc4d2ad12f16cc2d;hp=0e3bce702e532a0a203dfdf95b931911cf6985cd;hpb=2724e3d1df836f6ce40bc4227f1509e777de2e48;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 0e3bce7..93a9bb8 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,53 +1,61 @@ -s ::= ws grammar ws => "gram" -ws !::= w** -grammar ::= r +/ ws => "grammar" -r ::= word ^"::=" alternatives /ws - | word ^"!::=" alternatives /ws - -alternatives ::= equiAlt +/ (ws ">" ws) -equiAlt ::= conjuncts +/ (ws "|" ws) - -conjuncts ::= sequence - | sequence ^"&" e*/ws /ws - | sequence ^"&~" e*/ws /ws - -sequence ::= e*/ws - (ws "/" e)? - (ws "=>" ws (word|quoted))? => "seq" - -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 + +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 ::= ~[\-\]\\] + | 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)+) "\"" +Quoted ::= "\"" ((~[\"\\] | escaped)+) "\"" | "\"\"" => "" escaped ::= "\\n" => "\n" | "\\r" => "\r" - | "\\" [~nr] + | "\\" ~[nr] +w ::= " " | "\n" | "\r" +ws ::= w** => () + | w** "//" ~[\n]* "\n" ws => () +wp ::= w++