cleanup of Repeat.java
[sbp.git] / tests / meta.g
1 //funkanomitron
2 s             = ws Grammar ws
3
4 Grammar::     = Declaration +/ ws
5
6 Declaration   = NonTerminal
7               | ^"#import" FileName            /ws
8               | ^"#import" FileName "as" Word  /ws
9
10 FileName::    = (~[\r\n ] | escaped)+ -> [\r\n ]
11
12 NonTerminal   = NonTerminal:: Word            ws  "=" ws RHS
13               | DropNT::      Word  "!"       ws  "=" ws RHS
14               | Colons::      Word  "::"      ws  "=" ws RHS
15               |               Word  "*"       ws ^"=" ws RHS
16               |               Word  "*/" Word ws ^"=" ws RHS
17        
18 RHS::         = ("|":: Sequence +/ (ws "|" ws)) +/ (ws ">" ws)
19
20 Elements::    = e*/ws
21
22 PreSequence   = Elements
23               | (Quoted|Word)   ^"::" PreSequence /ws
24               > PreSequence     ^"/"      e       /ws
25               | PreSequence     ^"->"     e       /ws
26
27 Sequence      = PreSequence
28               | Sequence ^"&"  Elements /ws
29               | ^"~~"  Elements /ws
30               | Sequence ^"&~" Elements /ws
31
32 e             =                                   e ^"!"
33               >                (Quoted|Word) ^":" e
34               >                NonTerminalReference:: Word
35               |                Literal:: Quoted
36               |                  ^"()"
37               |                  ^"{" PreSequence "}"    /ws
38               |                  ^"["  Range* "]"
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               |                  ^"^"   Quoted
49               |                  ^"`"   e
50               |                  ^"..."
51               |                   "(" Word  ^")"
52               >                  ^"(" RHS  ")"           /ws
53               |                 "~":: ("~" -> ~"~")!  e
54               |                  ^"\\{"
55               |                  ^"\\}"
56
57 Word::        = [.a-zA-Z0-9_]++ &~ "."+
58 Quoted::      = "\"" (~[\"\\] | escaped)+ "\""
59               | "\"\""
60
61 Range::       = ec
62               | ec "-" ec
63
64 ec            = ~[\-\]\\]
65               | escaped
66 escaped       = "\n"::  "\\n"
67               | "\r"::  "\\r"
68               |         "\\" ~[nr]
69
70 ws!          = [ \r\n]**
71              | [ \r\n]** "//" ~[\n]* "\n" ws