X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=b1552f1bdf129fe3a32e46e0c23d62ff3c189c86;hp=eb793c5fe91d9ac0b42fd7d66dcb26b9b438f16f;hb=22a2ca7685dcf29e9ddcc6e26443ea0277385fca;hpb=d643fa7e95ca16571a8621ded500abf0215fd5ae diff --git a/tests/meta.g b/tests/meta.g index eb793c5..b1552f1 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,36 +1,36 @@ -s = ws! Grammar ws! +s = ws Grammar ws -Grammar = NonTerminal +/ ws +Grammar:: = Declaration +/ ws -NonTerminal = Word "=" RHS /ws +Declaration = NonTerminal + | ^"#import" FileName /ws + | ^"#import" FileName "as" Word /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!) +FileName:: = (~[\r\n ] | escaped)+ -> [\r\n ] -Elements = e*/ws +NonTerminal = NonTerminal:: Word ws "=" ws RHS + | DropNT:: Word "!" ws "=" ws RHS + | Colons:: Word "::" ws "=" ws RHS + | Word "*" ws ^"=" ws RHS + | Word "*/" Word ws ^"=" ws RHS + +RHS:: = ("|":: Sequence +/ (ws "|" ws)) +/ (ws ">" ws) -PreSequence = ps:: Elements - | (Quoted|Word) ^"::" PreSequence /ws - > PreSequence ^"/" e /ws - | PreSequence ^"->" e /ws +Elements:: = e*/ws -Sequence = psx:: PreSequence - | Sequence ^"&" Elements /ws - | Sequence ^"&~" Elements /ws +PreSequence = Elements + | (Quoted|Word) ^"::" PreSequence /ws + > PreSequence ^"/" e /ws + | PreSequence ^"->" e /ws -ec = ~[\-\]\\] - | escaped +Sequence = PreSequence + | Sequence ^"&" Elements /ws + | Sequence ^"&~" Elements /ws -Range = ec - | ec ^"-" ec - -e = (Quoted|Word) ^":" e - > NonTerminalReference - | Literal +e = e ^"!" + > (Quoted|Word) ^":" e + > NonTerminalReference:: Word + | Literal:: Quoted | ^"()" | ^"{" PreSequence "}" /ws | ^"[" Range* "]" @@ -42,24 +42,26 @@ e = (Quoted|Word) ^":" e | e ^"*" /ws -> ~[*] | e ^"**/" e /ws | e ^"*/" e /ws - | e ^"!" | e ^"?" /ws | ^"^" Quoted - | Quoted ^"^" + | "(" Word ^")" > ^"(" RHS ")" /ws | ^"~" e + | ^"\\{" + | ^"\\}" + +Word:: = [.a-zA-Z0-9_]++ +Quoted:: = "\"" (~[\"\\] | escaped)+ "\"" + | "\"\"" -NonTerminalReference = Word -Literal = Quoted -Word = [a-zA-Z0-9_]++ -Quoted = "\"" ((~[\"\\] | escaped)+) "\"" - | "":: "\"\"" +Range:: = ec + | ec "-" ec + +ec = ~[\-\]\\] + | escaped +escaped = "\n":: "\\n" + | "\r":: "\\r" + | "\\" ~[nr] -escaped = "\n":: "\\n" - | "\r":: "\\r" - | "\\" ~[nr] +ws! = [ \r\n]** ("//" ~[\n]* "\n" ws)? -w = " " | "\n" | "\r" -ws = "()":: w** - | "()":: w** "//" (~[\n])* "\n" ws -wp = w++