X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=tests%2Fmeta.g;h=eb793c5fe91d9ac0b42fd7d66dcb26b9b438f16f;hb=d643fa7e95ca16571a8621ded500abf0215fd5ae;hp=c8230e6f1fe28a5d64d611daa7c04aa268b0cec7;hpb=80128a38a1c907f1860a5cb13769d691be059a5f;p=sbp.git diff --git a/tests/meta.g b/tests/meta.g index c8230e6..eb793c5 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,4 +1,4 @@ -s = !ws Grammar !ws +s = ws! Grammar ws! Grammar = NonTerminal +/ ws @@ -9,7 +9,7 @@ NonTerminal = Word "=" RHS /ws // #include (with renaming?) // ANTLR uses ! and ^ suffixes -RHS = (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws) +RHS = (Sequence +/ (ws! "|" ws!)) +/ (ws! ">" ws!) Elements = e*/ws @@ -29,8 +29,8 @@ Range = ec | ec ^"-" ec e = (Quoted|Word) ^":" e - > nonTerminal:: Word - | literal:: Quoted + > NonTerminalReference + | Literal | ^"()" | ^"{" PreSequence "}" /ws | ^"[" Range* "]" @@ -42,17 +42,19 @@ e = (Quoted|Word) ^":" e | e ^"*" /ws -> ~[*] | e ^"**/" e /ws | e ^"*/" e /ws - | ^"!" e /ws + | e ^"!" | e ^"?" /ws | ^"^" Quoted - | "(" Word ^")" /ws + | Quoted ^"^" > ^"(" 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]