X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=3227dca94baf0b6eec65ca42c68e0f820a3411a2;hb=665d5abdf0269ef5bd4cc4b93bb82b3f74bb0110;hp=d11981b5d8890588c9b874536c863f54684870cb;hpb=f1321301726919a74918c3f09e58e78f66017644;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index d11981b..3227dca 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,56 +1,49 @@ -s ::= Grammar ws => "gram" -w ::= " " - | "\n" - | "\r" -ws ::= w** => () - | w** "//" (~[\n]*) "\n" ws => () -wp ::= 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" - | (e+/ws !ws)? "^" Quoted (!ws e+/ws)? => "ps2" -psy ::= ps - | ps !wp ^"/" !ws e -psx ::= psy => "psy" -// | e "<-" psy /ws => "psyl" - | psy "->" e /ws => "psyr" -// | e "<-" psy "->" e /ws => "psylr" -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 - > ^"(" alternatives ")" /ws - | ^"~" e +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 (!wp "/" !ws e)? => "ps2" +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 + | "^" Quoted /ws => caret + + | "(" word ^")" /ws + > ^"(" RHS ")" /ws + | ^"~" e word ::= [a-zA-Z0-9_]++ Quoted ::= "\"" ((~[\"\\] | escaped)+) "\"" @@ -60,3 +53,7 @@ escaped ::= "\\n" => "\n" | "\\" ~[nr] +w ::= " " | "\n" | "\r" +ws ::= w** => () + | w** "//" ~[\n]* "\n" ws => () +wp ::= w++