X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=f06eb2f42010e4165a6b498eb7203b98d8645e84;hp=be8e435d9370275e14adcbe89137e28c612141b8;hb=61a0c83fd40b98292b2dfe1eaba237eb804b2cb4;hpb=1a249057cbfd2180910e46672eafee3af46ae470 diff --git a/tests/meta.g b/tests/meta.g index be8e435..f06eb2f 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,31 +1,40 @@ -s = ws grammar:Grammar ws -Grammar = NonTerminal +/ ws -NonTerminal = Word ^"=" RHS /ws - -RHS = (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws) +//funkanomitron +s = ws Grammar ws -Elements = e*/ws +Grammar:: = Declaration +/ ws -PreSequence = ps:: Elements - | (Quoted|Word) ^"::" PreSequence /ws - > PreSequence ^"/" e /ws - | PreSequence ^"->" e /ws +Declaration = NonTerminal + | ^"#import" FileName /ws + | ^"#import" FileName "as" Word /ws -Sequence = psx:: PreSequence - | Sequence ^"&" Elements /ws - | Sequence ^"&~" Elements /ws +FileName:: = (~[\r\n ] | escaped)+ -> [\r\n ] -ec = ~[\-\]\\] - | escaped +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 -Range = range:: ec - | ec ^"-" ec +PreSequence = Elements + | (Quoted|Word) ^"::" PreSequence /ws + > PreSequence ^"/" e /ws + | PreSequence ^"->" e /ws -e = (Quoted|Word) ^":" e - > nonTerminal:: Word - | literal:: Quoted +Sequence = PreSequence + | Sequence ^"&" Elements /ws + | ^"~~" Elements /ws + | Sequence ^"&~" Elements /ws + +e = e ^"!" + > (Quoted|Word) ^":" e + > NonTerminalReference:: Word + | Literal:: Quoted | ^"()" - | ^"{" Sequence "}" /ws + | ^"{" PreSequence "}" /ws | ^"[" Range* "]" | e ^"++" /ws -> ~[/] | e ^"+" /ws -> ~[+] @@ -35,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