X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=02464c31e2e0261a606b409b6fd0b2e158cf88b8;hp=03bd717eb9acf1410412b3de60be876ec8d5d3af;hb=df76fcb56242a90011500ab89092d2108350a8ab;hpb=ee2f84c26849ceecf34826f6a2b4f5e1d03a0f2b diff --git a/tests/meta.g b/tests/meta.g index 03bd717..02464c3 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,59 +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) +s = ws! Grammar ws! -sequence ::= e */ (w**) - > e */ (w**) ws ^"/" e +Grammar = NonTerminal +/ ws -ss ::= es => "seq" | 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|quoted) /ws +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 => "range" - | ec ^"-" ec +ec = ~[\-\]\\] + | escaped -e ::= word => "nonTerminal" - | [(][)] => "epsilon" - | ^"{" alternatives "}" /ws - | ^"[" (range*) "]" - | ^"[~" (range*) "]" - | ^"^" quoted /ws - | ^"!" e /ws +Range = ec + | ec ^"-" ec - | (e ws ^"**" > e ws ^"*") - | e ^"*/" e /ws - | (e ws ^"++" > e ws ^"+") - | e ^"+/" e /ws - | 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 - | quoted => "literal" - - | "(" word ^")" /ws - > ^"(" alternatives ")" /ws - -w !::= " " - | "//" ([~\n]*) "\n" - | "\n" - | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ -quoted ::= "\"" (([~\"\\] | escaped)+) "\"" - | "\"\"" => "" -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++