X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=ce2aa6f1ced6fdb1c231bdf8044a053f2526380a;hp=e81e67c9ff2caf04a419b7db517d895e8d6cf5fe;hb=47ea237a2a0f3daddcd1037fd9c2cfadbeae8ac8;hpb=6ba9ea820f9626a7504da6cf442e2cef1601914f diff --git a/tests/meta.g b/tests/meta.g index e81e67c..ce2aa6f 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,19 +1,25 @@ -s = gram:: !ws 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 = (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 + | (Quoted|Word) ^"::" PreSequence /ws + > PreSequence ^"/" e /ws + | PreSequence ^"->" e /ws + Sequence = psx:: PreSequence + | 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