checkpoint
[sbp.git] / tests / meta.g
1 s           ::=  !ws Grammar ws              => "gram"
2 Grammar     ::=  NonTerminal +/ ws           => "grammar"
3 NonTerminal ::=  word  ^"::=" RHS /ws
4
5 RHS         ::=  (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws)
6
7 Conjuncts   ::=  Sequence
8               |  Sequence ^"&"  Elements  /ws
9               |  Sequence ^"&~" Elements  /ws
10 Elements    ::=  e*/ws
11
12 psy         ::= Elements => "ps"
13               | psy !wp ^"/"  !ws e
14               | psy     ^"->"     e /ws
15 Sequence    ::= Quoted => "qprod"
16               > psy => "psx"
17               | psy  "=>" ^"[]"              /ws
18               | psy ^"=>" ("()"|word|Quoted) /ws
19
20 ec          ::= ~[\-\]\\]
21               | escaped
22
23 Range       ::= ec          => "range"
24               | ec ^"-" ec
25
26 e           ::=  word                          => "nonTerminal"
27               |  Quoted                        => "literal"
28               |    ^"()"
29               |    ^"{" Sequence "}"       /ws
30               |    ^"["  Range* "]"
31
32               |  e ^"++"                   /ws -> ~[/]
33               |  e ^"+"                    /ws -> ~[+]
34               |  e ^"++/" e                /ws        
35               |  e ^"+/"  e                /ws        
36               |  e ^"**"                   /ws -> ~[/]
37               |  e ^"*"                    /ws -> ~[*]
38               |  e ^"**/" e                /ws        
39               |  e ^"*/"  e                /ws        
40               |    ^"!"   e                /ws
41               |  e ^"?"                    /ws
42               |    ^"^" Quoted             /ws
43
44               |     "(" word         ^")"  /ws
45               >    ^"(" RHS  ")"           /ws
46               |    ^"~" e
47
48 word     ::= [a-zA-Z0-9_]++
49 Quoted   ::= "\"" ((~[\"\\] | escaped)+) "\""
50            | "\"\"" => ""
51 escaped  ::= "\\n" => "\n"
52            | "\\r" => "\r"
53            | "\\" ~[nr]
54
55
56 w           ::= " " | "\n" | "\r"
57 ws          ::=  w** => ()
58               |  w** "//" ~[\n]* "\n" ws => ()
59 wp          ::=  w++