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 psx         ::= psy                   => "psy"
15               | psy ^"->" e /ws
16 Sequence    ::= Quoted => "qprod"
17               > psx => "psx"
18               | psx  "=>" ^"[]"              /ws
19               | psx ^"=>" ("()"|word|Quoted) /ws
20
21 ec          ::= ~[\-\]\\]
22               | escaped
23
24 Range       ::= ec          => "range"
25               | ec ^"-" ec
26
27 e           ::=  word                          => "nonTerminal"
28               |  Quoted                        => "literal"
29               |    ^"()"
30               |    ^"{" Sequence "}"       /ws
31               |    ^"["  Range* "]"
32
33               |  e ^"++"                   /ws -> ~[/]
34               |  e ^"+"                    /ws -> ~[+]
35               |  e ^"++/" e                /ws        
36               |  e ^"+/"  e                /ws        
37               |  e ^"**"                   /ws -> ~[/]
38               |  e ^"*"                    /ws -> ~[*]
39               |  e ^"**/" e                /ws        
40               |  e ^"*/"  e                /ws        
41               |    ^"!"   e                /ws
42               |  e ^"?"                    /ws
43               |   "^" Quoted               /ws => caret
44
45               |     "(" word         ^")"  /ws
46               >    ^"(" RHS  ")"           /ws
47               |    ^"~" e
48
49 word     ::= [a-zA-Z0-9_]++
50 Quoted   ::= "\"" ((~[\"\\] | escaped)+) "\""
51            | "\"\"" => ""
52 escaped  ::= "\\n" => "\n"
53            | "\\r" => "\r"
54            | "\\" ~[nr]
55
56
57 w           ::= " " | "\n" | "\r"
58 ws          ::=  w** => ()
59               |  w** "//" ~[\n]* "\n" ws => ()
60 wp          ::=  w++