X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=02464c31e2e0261a606b409b6fd0b2e158cf88b8;hp=092cb9ebc5d426f9af5a80d9a5066836091def3f;hb=df76fcb56242a90011500ab89092d2108350a8ab;hpb=6470b3188790f3461508a9f290d70c344c6fedf2 diff --git a/tests/meta.g b/tests/meta.g index 092cb9e..02464c3 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,67 +1,66 @@ -s ::= ws grammar ws => "gram" -ws !::= w** -grammar ::= r $$ ws => "grammar" -r ::= word ^"::=" alternatives /ws - | word ^"!::=" alternatives /ws +// use 'a'-'z' or 'a-z' instead of [a-z]? +// EOF token? +// #include (with renaming?) -alternatives ::= equiAlt $$ (ws ">" ws) -equiAlt ::= conjuncts $$ (ws "|" ws) => "alternatives" +s = ws! Grammar ws! -sequence ::= es - > Es ws ^"/" e -Es ::= e %% (w**) -es ::= e %% (w**) +Grammar = NonTerminal +/ ws -ss ::= es | es ^"/" e /ws +NonTerminal = Word "=" RHS /ws + | Word "*" ws! ^"=" ws! RHS + | Word "*/" Word ws! ^"=" ws! RHS + +RHS = (Sequence +/ (ws! "|" ws!)) +/ (ws! ">" ws!) -conjuncts ::= rewrite - | rewrite ^"&" e%%ws /ws - | rewrite ^"&~" e%%ws /ws +Elements = e*/ws -rewrite ::= sequence /ws => "rewrite" - | sequence ^"=>" word /ws - | sequence ^"=>" quoted /ws - | sequence "=>" "()" /ws => "wrap" +PreSequence = Elements + | (Quoted|Word) ^"::" PreSequence /ws + > PreSequence ^"/" e /ws + | PreSequence ^"->" e /ws -ec ::= [~\-\]\\\~] - | escaped +Sequence = psx:: PreSequence + | Sequence ^"&" Elements /ws + | Sequence ^"&~" Elements /ws -range ::= ec => "range0" - | ec ^"-" ec => "range1" +ec = ~[\-\]\\] + | escaped -e ::= word => "nonTerminalY" - | [(][)] => "epsilon" - | ^"{" alternatives "}" /ws - | "[" (range*) "]" => "range" - | "[~" (range*) "]" => "rangex" - | e ^"%%" e /ws - | e ^"$$" e /ws - | e ^"?" /ws - | e ^"~/~" /ws +Range = ec + | ec ^"-" ec - | e ^"-" e /ws +e = (Quoted|Word) ^":" e + > NonTerminalReference + | Literal + | ^"()" + | ^"{" PreSequence "}" /ws + | ^"[" Range* "]" + | e ^"++" /ws -> ~[/] + | e ^"+" /ws -> ~[+] + | e ^"++/" e /ws + | e ^"+/" e /ws + | e ^"**" /ws -> ~[/] + | e ^"*" /ws -> ~[*] + | e ^"**/" e /ws + | e ^"*/" e /ws + | e ^"!" + | e ^"?" /ws + | ^"^" Quoted + > ^"(" RHS ")" /ws + | ^"~" e - | ^"!" e /ws - | "^" quoted /ws => "care" - | ^"`" e /ws - | e ^"#" /ws - | quoted => "literal" - - | (e ws ^"**" > e ws ^"*") - | (e ws ^"++" > e ws ^"+") - - | "(" word ^")" /ws - > ^"(" alternatives ")" /ws - -w !::= " " - | "//" ([~\n]*) "\n" - | "\n" - | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ => "sify" -quoted ::= "\"" (([~\"\\] | escaped)*) "\"" => "sify" -escaped ::= "\\n" => "\n" - | "\\r" => "\r" - | "\\" [~nr] +NonTerminalReference = Word +Literal = Quoted +Word = [a-zA-Z0-9_]++ +Quoted = "\"" ((~[\"\\] | escaped)+) "\"" + | EmptyString + EmptyString = "\"\"" +escaped = "\n":: "\\n" + | "\r":: "\\r" + | "\\" ~[nr] +w = " " | "\n" | "\r" +ws = "()":: w** + | "()":: w** "//" (~[\n])* "\n" ws +wp = w++