X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=e81e67c9ff2caf04a419b7db517d895e8d6cf5fe;hp=f16c60a384c40cc1dd1c3adb2d79607635c93da2;hb=6ba9ea820f9626a7504da6cf442e2cef1601914f;hpb=a4e47e7742e717f9fc72455f60cdbd16a7af9fe1 diff --git a/tests/meta.g b/tests/meta.g index f16c60a..e81e67c 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,59 +1,57 @@ -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 ::= Es ^"/" E /ws - > Es -Es ::= 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 ")" - -w !::= " " - | "//" [~\n]* "\n" - | "\n" - | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ => "sify" -quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify" -escaped ::= "\\n" => "\n" - | "\\r" => "\r" - | "\\" [~nr] +s = gram:: !ws Grammar ws +Grammar = grammar:: NonTerminal +/ ws +NonTerminal = word !wp ^"=" !wp RHS + +RHS = (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) + +Conjuncts = Sequence + | Sequence ^"&" Elements /ws + | Sequence ^"&~" Elements /ws +Elements = e*/ws + +PreSequence = ps:: Elements + | PreSequence !wp ^"/" !ws e + | PreSequence ^"->" e /ws + | (Quoted|word) ^"::" PreSequence /ws +Sequence = psx:: PreSequence + +ec = ~[\-\]\\] + | escaped + +Range = range:: ec + | ec ^"-" ec + +e = (Quoted|word) ^":" e + > nonTerminal:: word + | literal:: Quoted + | ^"()" + | ^"{" 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 + | "(" word ^")" /ws + > ^"(" RHS ")" /ws + | ^"~" e + > "^^":: "^" e + +word = [a-zA-Z0-9_]++ +Quoted = "\"" ((~[\"\\] | escaped)+) "\"" + | "":: "\"\"" +escaped = "\n":: "\\n" + | "\r":: "\\r" + | "\\" ~[nr] + + +w = " " | "\n" | "\r" +ws = "()":: w** + | "()":: w** "//" ~[\n]* "\n" ws +wp = w++