X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=tests%2Fmeta.g;h=8a5b7e17f3573d7272e103a720bd40ecaa84aa8e;hp=fecabcfda16097e07de76555a2e47a084260af22;hb=8633a1ff957ac9ccbafa5e897bc8b9f17eadab02;hpb=2f40527569777d1cadeadae484866f481912447f diff --git a/tests/meta.g b/tests/meta.g index fecabcf..8a5b7e1 100644 --- a/tests/meta.g +++ b/tests/meta.g @@ -1,59 +1,54 @@ -s ::= w* Grammar w* => "gram" -ws !::= w* -grammar ::= R+/ws => "grammar" -Grammar ::= R+ => "grammar" -R ::= word ^"::=" Alternatives - | word ^"!::=" Alternatives - -ec ::= [~\]\\\-\~] | escaped - -Alternatives ::= EquiAlt +/ ">" -EquiAlt ::= Conjuncts +/ "|" => "alternatives" - -sequence ::= Es ^"/" E /ws - > Es -Es ::= E+ - -Conjuncts ::= rewrite - | rewrite ^"&" sequence - | rewrite ^"&~" sequence - -rewrite ::= sequence /ws => "rewrite" - | sequence ^"=>" word /ws - | sequence ^"=>" quoted /ws - | sequence "=>" "()" /ws => "wrap" - -range ::= ec => "range0" | ec ^"-" ec => "range0" -E ::= word => "nonTerminalY" - | [(][)] => "epsilon" - | ^"{" Alternatives "}" - | "[" [\~]? range* "]" => "range" - | E ^"*/" E - | E ^"+/" E - | E ^"?" - | E ^"~/~" - - | E ^"-" E - - | ^"!" E - | "^" quoted => "care" - | ^"`" E - | E ^"#" - | quoted => "literal" +s ::= ws grammar ws => "gram" +ws !::= w** +wp !::= w++ +grammar ::= r +/ ws => "grammar" + +r ::= word ^"::=" alternatives /ws + | word ^"!::=" alternatives /ws + +alternatives ::= (conjuncts +/ (ws "|" ws)) +/ (ws ">" ws) + +conjuncts ::= sequence + | sequence ^"&" e*/ws /ws + | sequence ^"&~" e*/ws /ws - | (E ^"**" > E ^"*") - | (E ^"++" > E ^"+") +ps ::= e*/ws => "ps" + | (e+/ws ws)? "^" quoted (ws e+/ws)? => "ps2" +psx ::= ps + | ps wp ^"/" ws e +sequence ::= psx + | psx ^"=>" (word|quoted) /ws - | "(" word ^")" - > ^"(" Alternatives ")" +ec ::= [~\-\]\\\~] + | escaped +range ::= ec => "range" + | ec ^"-" ec + +e ::= word => "nonTerminal" + | quoted => "literal" + | ^"()" + | ^"{" sequence "}" /ws + | ^"[" range* "]" + | ^"[~" range* "]" + + | (e ws ^"**" > e ws ^"*") + | e ^"*/" e /ws + | (e ws ^"++" > e ws ^"+") + | e ^"+/" e /ws + | e ^"?" /ws + + | "(" word ^")" /ws + > ^"(" alternatives ")" /ws w !::= " " - | "//" [~\n]* "\n" + | "//" ([~\n]*) "\n" | "\n" | "\r" -an ::= [a-zA-Z0-9_] -word ::= an++ => "sify" -quoted ::= "\"" ([~\"\\] | escaped)* "\"" => "sify" +word ::= [a-zA-Z0-9_]++ +quoted ::= "\"" (([~\"\\] | escaped)+) "\"" + | "\"\"" => "" escaped ::= "\\n" => "\n" | "\\r" => "\r" | "\\" [~nr] + +