X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=cbfee2aaf3a8dacca295899ddcc610e41be7cc98;hb=b205c5ee125119b0372328b70e8a66164df18fd0;hp=cc33104b4536e4385dc2f0cc984f988186b1c64e;hpb=475743c156fc5b02e79cd787b3176f5fa1877f83;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index cc33104..cbfee2a 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,19 +1,24 @@ -s = ws gram:Grammar ws -Grammar = grammar:: NonTerminal +/ ws -NonTerminal = word !wp ^"=" !wp RHS +Grammar = NonTerminal +/ ws +s = !ws (grammar::Grammar) !ws +NonTerminal = Word ^"=" RHS /ws + +// use 'a'-'z' or 'a-z' instead of [a-z]? +// EOF token? +// #include (with renaming?) +// ANTLR uses ! and ^ suffixes RHS = (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws) Elements = e*/ws PreSequence = ps:: Elements - | PreSequence !wp ^"/" !ws e - | PreSequence ^"->" e /ws - | (Quoted|word) ^"::" PreSequence /ws + | (Quoted|Word) ^"::" PreSequence /ws + > PreSequence ^"/" e /ws + | PreSequence ^"->" e /ws Sequence = psx:: PreSequence - | Sequence !ws ^"&" !ws Elements - | Sequence !ws ^"&~" !ws Elements + | Sequence ^"&" Elements /ws + | Sequence ^"&~" Elements /ws ec = ~[\-\]\\] | escaped @@ -21,11 +26,11 @@ ec = ~[\-\]\\] Range = range:: ec | ec ^"-" ec -e = (Quoted|word) ^":" e - > nonTerminal:: word +e = (Quoted|Word) ^":" e + > nonTerminal:: Word | literal:: Quoted | ^"()" - | ^"{" Sequence "}" /ws + | ^"{" PreSequence "}" /ws | ^"[" Range* "]" | e ^"++" /ws -> ~[/] | e ^"+" /ws -> ~[+] @@ -38,20 +43,19 @@ e = (Quoted|word) ^":" e | ^"!" e /ws | e ^"?" /ws | ^"^" Quoted - | "(" word ^")" /ws + | "(" Word ^")" /ws > ^"(" RHS ")" /ws | ^"~" e - > "^^":: "^" e + > "^^":: "^" e -word = [a-zA-Z0-9_]++ +Word = [a-zA-Z0-9_]++ Quoted = "\"" ((~[\"\\] | escaped)+) "\"" | "":: "\"\"" escaped = "\n":: "\\n" | "\r":: "\\r" | "\\" ~[nr] - w = " " | "\n" | "\r" ws = "()":: w** - | "()":: w** "//" ~[\n]* "\n" ws + | "()":: w** "//" (~[\n])* "\n" ws wp = w++