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