X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=f06eb2f42010e4165a6b498eb7203b98d8645e84;hp=3ee8fdf2e57c1168af2f8f6d82887cfcac3cf367;hb=61a0c83fd40b98292b2dfe1eaba237eb804b2cb4;hpb=b318adb49d46a596314d7b7c0dd9f52681abb449 diff --git a/tests/meta.g b/tests/meta.g index 3ee8fdf..f06eb2f 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,37 +1,40 @@ +//funkanomitron +s = ws Grammar ws -// use 'a'-'z' or 'a-z' instead of [a-z]? -// EOF token? -// #include (with renaming?) -// ANTLR uses ! and ^ suffixes +Grammar:: = Declaration +/ ws -s = !ws (grammar::Grammar) !ws -Grammar = NonTerminal +/ ws -NonTerminal = Word ^"=" RHS /ws - -RHS = (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws) +Declaration = NonTerminal + | ^"#import" FileName /ws + | ^"#import" FileName "as" Word /ws -Elements = e*/ws +FileName:: = (~[\r\n ] | escaped)+ -> [\r\n ] -PreSequence = ps:: Elements - | (Quoted|Word) ^"::" PreSequence /ws - > PreSequence ^"/" e /ws - | PreSequence ^"->" 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) -Sequence = psx:: PreSequence - | Sequence ^"&" Elements /ws - | Sequence ^"&~" Elements /ws +Elements:: = e*/ws -ec = ~[\-\]\\] - | escaped +PreSequence = Elements + | (Quoted|Word) ^"::" PreSequence /ws + > PreSequence ^"/" e /ws + | PreSequence ^"->" e /ws -Range = range:: ec - | ec ^"-" ec +Sequence = PreSequence + | Sequence ^"&" Elements /ws + | ^"~~" Elements /ws + | Sequence ^"&~" Elements /ws -e = (Quoted|Word) ^":" e - > nonTerminal:: Word - | literal:: Quoted +e = e ^"!" + > (Quoted|Word) ^":" e + > NonTerminalReference:: Word + | Literal:: Quoted | ^"()" - | ^"{" PreSequence "}" /ws + | ^"{" PreSequence "}" /ws | ^"[" Range* "]" | e ^"++" /ws -> ~[/] | e ^"+" /ws -> ~[+] @@ -41,22 +44,34 @@ e = (Quoted|Word) ^":" e | e ^"*" /ws -> ~[*] | e ^"**/" e /ws | e ^"*/" e /ws - | ^"!" e /ws | e ^"?" /ws | ^"^" Quoted - | "(" Word ^")" /ws + | ^"`" e + | ^"..." + | "(" Word ^")" > ^"(" RHS ")" /ws - | ^"~" e - > "^^":: "^" e - -Word = [a-zA-Z0-9_]++ -Quoted = "\"" ((~[\"\\] | escaped)+) "\"" - | "":: "\"\"" -escaped = "\n":: "\\n" - | "\r":: "\\r" - | "\\" ~[nr] - -w = " " | "\n" | "\r" -ws = "()":: w** - | "()":: w** "//" ~[\n]* "\n" ws -wp = w++ + | "~":: ("~" -> ~"~")! e + | ^"\\{" + | ^"\\}" + | ^">>" + | ^"<<" + +Word:: = [.a-zA-Z0-9_]++ &~ "."+ +Quoted:: = "\"" (~[\"\\] | escaped)+ "\"" + | "\"\"" + +Range:: = ec + | ec "-" ec + | "<<":: [<][<] + | ">>":: [>][>] + +ec = ~[\-\]\\<>] + | [>] -> ~[>] + | [<] -> ~[<] + | escaped +escaped = "\n":: "\\n" + | "\r":: "\\r" + | "\\" ~[nr] + +ws! = [ \r\n]** + | [ \r\n]** "//" ~[\n]* "\n" ws