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