X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=eba7a6d82b25c908e9e50c0795bb2cd6e15ee24f;hp=019d5e37ce7a96ea2a99d5bbf97d8086f3ce7357;hb=61446887e40e11e0a7374e591e6d6c25c922093f;hpb=025ebe3e707adc361fbfbae9ea6120699f5d045a diff --git a/tests/meta.g b/tests/meta.g index 019d5e3..eba7a6d 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,60 +1,58 @@ -s ::= !ws Grammar ws => "gram" -Grammar ::= NonTerminal +/ ws => "grammar" -NonTerminal ::= word ^"::=" RHS /ws +s = gram:: !ws Grammar ws +Grammar = grammar:: NonTerminal +/ ws +NonTerminal = word !wp ^"=" !wp RHS + +RHS = (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) -RHS ::= (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws) - -Conjuncts ::= Sequence +Conjuncts = Sequence | Sequence ^"&" Elements /ws | Sequence ^"&~" Elements /ws -Elements ::= e*/ws - -psy ::= Elements => "ps" - | Elements !wp "/" !ws e => "ps2" -psx ::= psy => "psy" - | psy ^"->" e /ws -Sequence ::= Quoted => "qprod" - > psx => "psx" - | psx "=>" ^"[]" /ws - | psx ^"=>" ("()"|word|Quoted) /ws - -ec ::= ~[\-\]\\] +Elements = e*/ws + +PreSequence = ps:: Elements + | PreSequence !wp ^"/" !ws e + | PreSequence ^"->" e /ws + | (Quoted|word) ^"::" PreSequence /ws + | PreSequence ^"=>" ("[]"|"()"|word|Quoted) /ws +Sequence = psx:: PreSequence + +ec = ~[\-\]\\] | escaped -Range ::= ec => "range" - | ec ^"-" ec - -e ::= word => "nonTerminal" - | Quoted => "literal" - | ^"()" - | ^"{" Sequence "}" /ws - | ^"[" Range* "]" - - | e ^"++" /ws -> ~[/] - | e ^"+" /ws -> ~[+] - | e ^"++/" e /ws - | e ^"+/" e /ws - | e ^"**" /ws -> ~[/] - | e ^"*" /ws -> ~[*] - | e ^"**/" e /ws - | e ^"*/" e /ws - | ^"!" e /ws - | e ^"?" /ws - | "^" Quoted /ws => caret - - | "(" word ^")" /ws - > ^"(" RHS ")" /ws - | ^"~" e - -word ::= [a-zA-Z0-9_]++ -Quoted ::= "\"" ((~[\"\\] | escaped)+) "\"" - | "\"\"" => "" -escaped ::= "\\n" => "\n" - | "\\r" => "\r" - | "\\" ~[nr] - - -w ::= " " | "\n" | "\r" -ws ::= w** => () +Range = range:: ec + | ec ^"-" ec + +e = (Quoted|word) ^":" e + > nonTerminal:: word + | literal:: Quoted + | ^"()" + | ^"{" Sequence "}" /ws + | ^"[" Range* "]" + | e ^"++" /ws -> ~[/] + | e ^"+" /ws -> ~[+] + | e ^"++/" e /ws + | e ^"+/" e /ws + | e ^"**" /ws -> ~[/] + | e ^"*" /ws -> ~[*] + | e ^"**/" e /ws + | e ^"*/" e /ws + | ^"!" e /ws + | e ^"?" /ws + | ^"^" Quoted /ws + + | "(" word ^")" /ws + > ^"(" RHS ")" /ws + | ^"~" 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++ +wp = w++