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