X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=b1552f1bdf129fe3a32e46e0c23d62ff3c189c86;hp=be8e435d9370275e14adcbe89137e28c612141b8;hb=22a2ca7685dcf29e9ddcc6e26443ea0277385fca;hpb=1a249057cbfd2180910e46672eafee3af46ae470 diff --git a/tests/meta.g b/tests/meta.g index be8e435..b1552f1 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,31 +1,38 @@ -s = ws grammar:Grammar ws -Grammar = NonTerminal +/ ws -NonTerminal = Word ^"=" RHS /ws - -RHS = (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws) +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 + | Sequence ^"&~" Elements /ws + +e = e ^"!" + > (Quoted|Word) ^":" e + > NonTerminalReference:: Word + | Literal:: Quoted | ^"()" - | ^"{" Sequence "}" /ws + | ^"{" PreSequence "}" /ws | ^"[" Range* "]" | e ^"++" /ws -> ~[/] | e ^"+" /ws -> ~[+] @@ -35,22 +42,26 @@ e = (Quoted|Word) ^":" e | e ^"*" /ws -> ~[*] | e ^"**/" e /ws | e ^"*/" e /ws - | ^"!" e /ws | e ^"?" /ws | ^"^" Quoted - | "(" Word ^")" /ws + | "(" 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++ + | ^"\\{" + | ^"\\}" + +Word:: = [.a-zA-Z0-9_]++ +Quoted:: = "\"" (~[\"\\] | escaped)+ "\"" + | "\"\"" + +Range:: = ec + | ec "-" ec + +ec = ~[\-\]\\] + | escaped +escaped = "\n":: "\\n" + | "\r":: "\\r" + | "\\" ~[nr] + +ws! = [ \r\n]** ("//" ~[\n]* "\n" ws)? +