X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=0f690221b0a37908bf4a5bab95da6670be7eb4bb;hp=7b1595d32d3195063ba75319145966c0715317c9;hb=c366dacc334fe2e35835164f5a37d3eebb2ca6d5;hpb=b39089b9e525f796a9f31e4707aac5ac0d6cfc3b diff --git a/tests/meta.g b/tests/meta.g index 7b1595d..0f69022 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,58 +1,60 @@ -s ::= w* Grammar w* => "gram" -ws !::= w* -grammar ::= R+/ws => "grammar" -Grammar ::= R+ => "grammar" -R ::= word ^"::=" Alternatives - | word ^"!::=" Alternatives - -ec ::= [~\]\\\-\~] | escaped - -Alternatives ::= EquiAlt +/ ">" -EquiAlt ::= Conjuncts +/ "|" => "alternatives" - -Sequence ::= E+ ^"/" E - > E+ - -Conjuncts ::= rewrite - | rewrite ^"&" Sequence - | rewrite ^"&~" Sequence - -rewrite ::= Sequence /ws => "rewrite" - | Sequence ^"=>" word /ws - | Sequence ^"=>" quoted /ws - | Sequence "=>" "()" /ws => "wrap" - -range ::= ec => "range0" | ec ^"-" ec => "range0" -E ::= word => "nonTerminalY" - | [(][)] => "epsilon" - | ^"{" Alternatives "}" - | "[" [\~]? range* "]" => "range" - | E ^"*/" E - | E ^"+/" E - | E ^"?" - | E ^"~/~" - - | E ^"-" E - - | ^"!" E - | "^" quoted => "care" - | ^"`" E - | E ^"#" - | quoted => "literal" - - | (E ^"**" > E ^"*") - | (E ^"++" > E ^"+") - - | "(" word ^")" - > ^"(" Alternatives ")" +s ::= Grammar ws => "gram" +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 "=>" ^"[]" /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 + + | "(" word ^")" /ws + > ^"(" alternatives ")" /ws + | ^"~" e w !::= " " - | "//" [~\n]* "\n" | "\n" | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ => "sify" -quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify" +word ::= [a-zA-Z0-9_]++ +Quoted ::= "\"" ((~[\"\\] | escaped)+) "\"" + | "\"\"" => "" escaped ::= "\\n" => "\n" | "\\r" => "\r" - | "\\" [~nr] + | "\\" ~[nr] + +