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