X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=02464c31e2e0261a606b409b6fd0b2e158cf88b8;hp=72e166529f276fe1e55c57130c66f1d135ac0b54;hb=df76fcb56242a90011500ab89092d2108350a8ab;hpb=50fd2646f65c18357e0639ec0737d329f2072388 diff --git a/tests/meta.g b/tests/meta.g index 72e1665..02464c3 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,21 +1,23 @@ - // use 'a'-'z' or 'a-z' instead of [a-z]? // EOF token? // #include (with renaming?) -// ANTLR uses ! and ^ suffixes -s = !ws (grammar::Grammar) !ws +s = ws! Grammar ws! + Grammar = NonTerminal +/ ws -NonTerminal = Word ^"=" RHS /ws - -RHS = (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws) + +NonTerminal = Word "=" RHS /ws + | Word "*" ws! ^"=" ws! RHS + | Word "*/" Word ws! ^"=" ws! RHS + +RHS = (Sequence +/ (ws! "|" ws!)) +/ (ws! ">" ws!) Elements = e*/ws -PreSequence = ps:: Elements - | (Quoted|Word) ^"::" PreSequence /ws - > PreSequence ^"/" e /ws - | PreSequence ^"->" e /ws +PreSequence = Elements + | (Quoted|Word) ^"::" PreSequence /ws + > PreSequence ^"/" e /ws + | PreSequence ^"->" e /ws Sequence = psx:: PreSequence | Sequence ^"&" Elements /ws @@ -24,15 +26,14 @@ Sequence = psx:: PreSequence ec = ~[\-\]\\] | escaped -Range = range:: ec - | ec ^"-" ec +Range = ec + | ec ^"-" ec e = (Quoted|Word) ^":" e - > - nonTerminal:: Word - | literal:: Quoted + > NonTerminalReference + | Literal | ^"()" - | ^"{" PreSequence "}" /ws + | ^"{" PreSequence "}" /ws | ^"[" Range* "]" | e ^"++" /ws -> ~[/] | e ^"+" /ws -> ~[+] @@ -42,22 +43,24 @@ e = (Quoted|Word) ^":" e | e ^"*" /ws -> ~[*] | e ^"**/" e /ws | e ^"*/" e /ws - | ^"!" e /ws + | e ^"!" | 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)+) "\"" + | EmptyString + EmptyString = "\"\"" + escaped = "\n":: "\\n" | "\r":: "\\r" | "\\" ~[nr] w = " " | "\n" | "\r" ws = "()":: w** - | "()":: w** "//" ~[\n]* "\n" ws + | "()":: w** "//" (~[\n])* "\n" ws wp = w++