X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=f06eb2f42010e4165a6b498eb7203b98d8645e84;hp=11cb9f8f17f8099f7529151a4fb7d4858d2c8404;hb=61a0c83fd40b98292b2dfe1eaba237eb804b2cb4;hpb=f3b4ef0d81d572694905f4fe284cac6311a29ea4 diff --git a/tests/meta.g b/tests/meta.g index 11cb9f8..f06eb2f 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,45 +1,38 @@ -// use 'a'-'z' or 'a-z' instead of [a-z]? -// EOF token? -// #include (with renaming?) +//funkanomitron +s = ws Grammar ws -s = ws! Grammar ws! +Grammar:: = Declaration +/ ws -Grammar = Declaration +/ ws +Declaration = NonTerminal + | ^"#import" FileName /ws + | ^"#import" FileName "as" Word /ws -Declaration = NonTerminal - | ^"#import" ws! FileName //(ws! "as" ws! Prefix)? +FileName:: = (~[\r\n ] | escaped)+ -> [\r\n ] -//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 +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!) - -Elements = e*/ws - -PreSequence = Elements - | (Quoted|Word) ^"::" PreSequence /ws - > PreSequence ^"/" e /ws - | PreSequence ^"->" e /ws +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 = ec - | ec ^"-" ec +Sequence = PreSequence + | Sequence ^"&" Elements /ws + | ^"~~" Elements /ws + | Sequence ^"&~" Elements /ws -e = (Quoted|Word) ^":" e - > NonTerminalReference - | Literal +e = e ^"!" + > (Quoted|Word) ^":" e + > NonTerminalReference:: Word + | Literal:: Quoted | ^"()" | ^"{" PreSequence "}" /ws | ^"[" Range* "]" @@ -51,24 +44,34 @@ e = (Quoted|Word) ^":" e | e ^"*" /ws -> ~[*] | e ^"**/" e /ws | e ^"*/" e /ws - | e ^"!" | e ^"?" /ws | ^"^" Quoted + | ^"`" e + | ^"..." + | "(" Word ^")" > ^"(" RHS ")" /ws - | ^"~" e + | "~":: ("~" -> ~"~")! e + | ^"\\{" + | ^"\\}" + | ^">>" + | ^"<<" + +Word:: = [.a-zA-Z0-9_]++ &~ "."+ +Quoted:: = "\"" (~[\"\\] | escaped)+ "\"" + | "\"\"" -NonTerminalReference = Word -Literal = Quoted -Word = [a-zA-Z0-9_]++ -Quoted = "\"" ((~[\"\\] | escaped)+) "\"" - | EmptyString - EmptyString = "\"\"" +Range:: = ec + | ec "-" ec + | "<<":: [<][<] + | ">>":: [>][>] -escaped = "\n":: "\\n" - | "\r":: "\\r" - | "\\" ~[nr] +ec = ~[\-\]\\<>] + | [>] -> ~[>] + | [<] -> ~[<] + | escaped +escaped = "\n":: "\\n" + | "\r":: "\\r" + | "\\" ~[nr] -w = " " | "\n" | "\r" -ws = "()":: w** - | "()":: w** "//" (~[\n])* "\n" ws -wp = w++ +ws! = [ \r\n]** + | [ \r\n]** "//" ~[\n]* "\n" ws