X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=845af526ba34d8b783b90952d02cc06927073819;hp=a540d78e7ab107f058b819b7c567c1a3eb379989;hb=225993309e6183afa9a88fc13d39df56be54b992;hpb=b14c82d2c557d38194abc5b0ebbacc87e880b709 diff --git a/tests/meta.g b/tests/meta.g index a540d78..845af52 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,20 +1,26 @@ -s = gram:: !ws 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 + +blah = "Grammar" -RHS = (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) +RHS = (Sequence +/ (!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 - | PreSequence ^"=>" ("[]"|"()"|word|Quoted) /ws + | (Quoted|Word) ^"::" PreSequence /ws + > PreSequence ^"/" e /ws + | PreSequence ^"->" e /ws + Sequence = psx:: PreSequence + | Sequence ^"&" Elements /ws + | Sequence ^"&~" Elements /ws ec = ~[\-\]\\] | escaped @@ -22,11 +28,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,21 +44,20 @@ e = (Quoted|word) ^":" e | e ^"*/" e /ws | ^"!" e /ws | e ^"?" /ws - | ^"^" Quoted /ws - - | "(" word ^")" /ws + | ^"^" Quoted + | "(" Word ^")" /ws > ^"(" RHS ")" /ws | ^"~" 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++