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