X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=571b26c97f97e298a0ee7aedace44f233c4d7ec5;hb=db888e59c3b40da15ad996ec84d1595bc44e042e;hp=0d2be6f86f6a9a577404da3453f0469c1fd18df2;hpb=df32ec862cecf0851a7f7342582b5786d04a4771;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index 0d2be6f..571b26c 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,6 +1,13 @@ -s = ws grammar:Grammar ws +s = !ws Grammar !ws + Grammar = NonTerminal +/ ws -NonTerminal = Word !wp ^"=" !wp RHS + +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) @@ -8,24 +15,24 @@ Elements = e*/ws PreSequence = ps:: Elements | (Quoted|Word) ^"::" PreSequence /ws - > PreSequence !wp ^"/" !ws e - | PreSequence ^"->" e /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 -Range = range:: ec - | ec ^"-" ec +Range = ec + | ec ^"-" ec e = (Quoted|Word) ^":" e - > nonTerminal:: Word - | literal:: Quoted + > NonTerminalReference + | Literal | ^"()" - | ^"{" Sequence "}" /ws + | ^"{" PreSequence "}" /ws | ^"[" Range* "]" | e ^"++" /ws -> ~[/] | e ^"+" /ws -> ~[+] @@ -38,19 +45,20 @@ e = (Quoted|Word) ^":" e | ^"!" e /ws | e ^"?" /ws | ^"^" Quoted - | "(" Word ^")" /ws > ^"(" RHS ")" /ws | ^"~" e - > "^^":: "^" e -Word = [a-zA-Z0-9_]++ -Quoted = "\"" ((~[\"\\] | escaped)+) "\"" - | "":: "\"\"" +NonTerminalReference = Word +Literal = Quoted +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++