X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=062bf2544ea0b95c19b80471bef335b2b487b6c6;hp=cc33104b4536e4385dc2f0cc984f988186b1c64e;hb=0ab024f487647f99eb000345c29c2f8e9b52a200;hpb=475743c156fc5b02e79cd787b3176f5fa1877f83 diff --git a/tests/meta.g b/tests/meta.g index cc33104..062bf25 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,19 +1,25 @@ -s = ws gram:Grammar ws -Grammar = grammar:: NonTerminal +/ ws -NonTerminal = word !wp ^"=" !wp RHS + +// use 'a'-'z' or 'a-z' instead of [a-z]? +// EOF token? +// #include (with renaming?) +// ANTLR uses ! and ^ suffixes + +s = ws grammar:Grammar ws +Grammar = NonTerminal +/ ws +NonTerminal = Word ^"=" RHS /ws 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 +27,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,19 +44,18 @@ e = (Quoted|word) ^":" e | ^"!" e /ws | e ^"?" /ws | ^"^" Quoted - | "(" word ^")" /ws + | "(" 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