checkpoint
[sbp.git] / tests / archscript.g
1 // A grammar for assembling archsim networks
2
3 s               = !ws (Statement +/ ws) !ws
4
5 Statement       = Import | Instance | Settings | Operations
6
7 Settings        = "settings" (Setting+/newline) /newline
8 Setting         = Name ^"=" quoted              /ws
9
10 Import          = ^"import" JavaClassName "as" Type  /ws
11 JavaClassName   = Name +/ "."
12
13 Instance        = ^"component" !ws ComponentName !ws ":" !ws Type (!newline Connection +/ newline)?
14
15 Connection      = Port ^"->" ForeignPort   /ws
16                 | Port ^"<-" ForeignPort   /ws
17
18 ForeignPort     = ComponentName ^"." Port
19
20 Type            = Name
21 Port            = Name
22 ComponentName   = Name
23 Name            = string:: [a-zA-Z0-9_]++
24
25 quoted          = "\"" ~[\"]* "\""
26 newline         = !ws "\n" !ws
27 ws              = [\r\n ]**
28                 | [\r\n ]** !Comment !ws
29 Comment         = "//" ~[\n]* "\n"
30                 | "/*" ~[\n]* "*/"
31
32 Operations      = ^"operations" (Operation+/newline) /newline
33 Operation       = ^"build_GASP_model"
34                 | ^"output" quoted                   /ws
35                 | ^"journal" quoted                  /ws
36                 | ^"error" quoted                    /ws
37                 | ^"info" quoted                     /ws
38                 | ^"run" [0-9]++                     /ws
39                 | ^"step" [0-9]++                    /ws
40                 | ^"self_check"
41                 | ^"reset"
42                 | ^"print_parameters"
43                 | ^"print_components"
44                 | ^"print_model"
45                 | ^"print_model_description"