X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=43f539a77a4f0c4229a75a5cf9b6bdd3cb0ddede;hp=7b1595d32d3195063ba75319145966c0715317c9;hb=86e7e1298601b60df964e3c0a71f3fe3cca230b8;hpb=b39089b9e525f796a9f31e4707aac5ac0d6cfc3b diff --git a/tests/meta.g b/tests/meta.g index 7b1595d..43f539a 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,58 +1,59 @@ -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 ")" - -w !::= " " - | "//" [~\n]* "\n" - | "\n" - | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ => "sify" -quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify" -escaped ::= "\\n" => "\n" +s = !ws Grammar ws => "gram" +Grammar = NonTerminal +/ ws => "grammar" +NonTerminal = word !wp ^"=" !wp RHS + +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)+) "\"" + | "\"\"" => "" +escaped = "\\n" => "\n" | "\\r" => "\r" - | "\\" [~nr] + | "\\" ~[nr] + + +w = " " | "\n" | "\r" +ws = w** => () + | w** "//" ~[\n]* "\n" ws => () +wp = w++