X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=17f039903c16260fee556f23eac42f9c3f45dac6;hp=f414867da2c83faf7a344d9353d24dc89932b750;hb=4378d20232cd88fb2a57edc5a5114f952ab58a18;hpb=8129e3bcdf7df528a636daf66e0b35b1dceb153f diff --git a/tests/meta.g b/tests/meta.g index f414867..17f0399 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,32 +1,40 @@ +// use 'a'-'z' or 'a-z' instead of [a-z]? +// EOF token? +// #include (with renaming?) + s = ws! Grammar ws! -Grammar = NonTerminal +/ ws +Grammar = Declaration +/ ws -NonTerminal = Word "=" RHS /ws +Declaration = NonTerminal + | ^"#import" ws! FileName (ws! "as" ws! Word)? -// use 'a'-'z' or 'a-z' instead of [a-z]? -// EOF token? -// #include (with renaming?) - +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 +PreSequence = Elements | (Quoted|Word) ^"::" PreSequence /ws > PreSequence ^"/" e /ws | PreSequence ^"->" e /ws -PS = Elements Sequence = psx:: PreSequence - | Sequence ^"&" PS /ws - | Sequence ^"&~" PS /ws + | Sequence ^"&" Elements /ws + | Sequence ^"&~" Elements /ws ec = ~[\-\]\\] | escaped Range = ec - | ec ^"-" ec + | ec "-" ec e = (Quoted|Word) ^":" e > NonTerminalReference @@ -50,15 +58,16 @@ e = (Quoted|Word) ^":" e NonTerminalReference = Word Literal = Quoted -Word = [a-zA-Z0-9_]++ +Word = [.a-zA-Z0-9_]++ Quoted = "\"" ((~[\"\\] | escaped)+) "\"" - | "":: "\"\"" + | EmptyString + EmptyString = "\"\"" escaped = "\n":: "\\n" | "\r":: "\\r" | "\\" ~[nr] w = " " | "\n" | "\r" -ws = "()":: w** - | "()":: w** "//" (~[\n])* "\n" ws +ws = w** + | w** "//" (~[\n])*! "\n" ws! wp = w++