checkpoint
[sbp.git] / tests / meta.g
1 s         ::=  w* Grammar w*                  => "gram"
2 Grammar   ::=  R+ => "grammar"
3 R         ::=  word  ^"::=" Alternatives
4             |  word ^"!::=" Alternatives
5
6 ec        ::=  [~\]\\\-\~] | escaped
7
8 Alternatives  ::=  EquiAlt   +/ ">"
9 EquiAlt       ::=  Conjuncts +/ "|"                 => "alternatives"
10
11 Sequence    ::= E+ ^"/" E
12               > E+
13
14 Conjuncts   ::=  Rewrite
15               |  Rewrite ^"&"  Sequence
16               |  Rewrite ^"&~" Sequence
17
18 Rewrite  ::=  Sequence                             => "rewrite"
19            |  Sequence ^"=>" word
20            |  Sequence ^"=>" quoted
21            |  Sequence  "=>" "()"                  => "wrap"
22
23 range    ::= ec => "range0" | ec ^"-" ec      => "range0"
24 E        ::= word                             => "nonTerminalY"
25            |    [(][)] => "epsilon"
26            |    ^"{" Alternatives "}"
27            |     "[" [\~]?  range* "]"        => "range"
28            |  E ^"*/" E
29            |  E ^"+/" E
30            |  E ^"?"
31            |  E ^"~/~"
32
33            |  E ^"-"  E
34
35            |    ^"!" E
36            |     "^" quoted => "care"
37            |    ^"`" E
38            |  E ^"#"
39            |  quoted                        => "literal"
40
41            |  (E ^"**" > E ^"*")
42            |  (E ^"++" > E ^"+")
43
44            |     "(" word ^")"
45            >    ^"(" Alternatives ")"
46
47 w       !::= " "
48            | "//" [~\n]* "\n"
49            | "\n"
50            | "\r"
51 an       ::= [a-zA-Z0-9_]
52 word     ::= an++                           => "sify"
53 quoted   ::= "\"" ([~\"\\] | escaped)* "\"" => "sify"
54 escaped  ::= "\\n" => "\n"
55            | "\\r" => "\r"
56            | "\\" [~nr]