X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=807f15f080c93a0453c3a452db883844f3ec69ae;hp=5723e6d1522bb71a9ef3f25357e705fdc201bd88;hb=5964a1161340a16d7dea471372737f2474576ceb;hpb=107df9a4aee6ba593b64d3bbe8b2efac84596cad diff --git a/tests/meta.g b/tests/meta.g index 5723e6d..807f15f 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,52 +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 - -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 + +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" + | ec ^"-" ec + +e ::= + (Quoted|word) ^":" 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++