X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=11cb9f8f17f8099f7529151a4fb7d4858d2c8404;hp=571b26c97f97e298a0ee7aedace44f233c4d7ec5;hb=f3b4ef0d81d572694905f4fe284cac6311a29ea4;hpb=db888e59c3b40da15ad996ec84d1595bc44e042e diff --git a/tests/meta.g b/tests/meta.g index 571b26c..11cb9f8 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,22 +1,31 @@ -s = !ws Grammar !ws - -Grammar = NonTerminal +/ ws - -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) + +s = ws! Grammar ws! + +Grammar = Declaration +/ ws + +Declaration = NonTerminal + | ^"#import" ws! FileName //(ws! "as" ws! Prefix)? + +//Prefix = ([a-zA-Z] ".")+ "*" +FileName = FileNameChar+ -> [\r\n ] +FileNameChar = Space:: "\\ " + | ~[\r\n ] + +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 @@ -42,7 +51,7 @@ e = (Quoted|Word) ^":" e | e ^"*" /ws -> ~[*] | e ^"**/" e /ws | e ^"*/" e /ws - | ^"!" e /ws + | e ^"!" | e ^"?" /ws | ^"^" Quoted > ^"(" RHS ")" /ws @@ -52,7 +61,8 @@ NonTerminalReference = Word Literal = Quoted Word = [a-zA-Z0-9_]++ Quoted = "\"" ((~[\"\\] | escaped)+) "\"" - | "":: "\"\"" + | EmptyString + EmptyString = "\"\"" escaped = "\n":: "\\n" | "\r":: "\\r"