3 Parses Erlang configuration files
5 Author: Raphael Pinson <raphael.pinson@camptocamp.com>
8 This lens tries to keep as close as possible to `http://www.erlang.org/doc/man/config.html` where possible.
11 This file is licenced under the LGPL v2+, like the rest of Augeas.
16 About: Configuration files
17 This lens applies to Erlang configuration files. See <filter>.
20 The <Test_Erlang> file contains various examples and tests.
25 (* Group: Spacing Functions *)
28 let space = del /[ \t\n]*/ ""
31 Add spaces to the left of char *)
32 let lspace (char:string) = del (/[ \t\n]*/ . char) char
35 Add spaces to the right of char *)
36 let rspace (char:string) = del (char . /[ \t\n]*/ ) char
39 Add spaces to the left or right of char *)
40 let lrspace (char:string) = del (/[ \t\n]*/ . char . /[ \t\n]*/ ) char
43 (* Group: Separators *)
46 Left square bracket *)
50 Right square bracket *)
54 Left curly brackets *)
58 Right curly brackets *)
62 Left glob separator *)
66 Right glob separator *)
73 (* Group: Value types *)
76 An optional list of elements, in square brackets *)
77 let opt_list (lns:lens) = rspace lbrack
78 . (Build.opt_list lns (lrspace comma) . space)?
82 Store a <Rx.integer> *)
83 let integer = store Rx.integer
86 Store a decimal value *)
87 let decimal = store /[0-9]+(.[0-9]+)?/
90 Store a quoted value *)
91 let quoted = Quote.do_quote (store /[^,\n}{]+/)
94 Store a bare <Rx.word> *)
95 let bare = store Rx.word
98 Store a boolean value *)
99 let boolean = store /true|false/
102 Store a path (<quoted>) *)
107 let glob = Util.del_str lglob . store /[^\n"]+/ . Util.del_str rglob
110 Make a "value" subnode for arrays/tuples *)
111 let make_value (lns:lens) = [ label "value" . lns ]
114 (* Group: Store types *)
118 let value (kw:regexp) (sto:lens) =
127 let tuple (one:lens) (two:lens) =
130 . [ label "value" . one ]
132 . [ label "value" . two ]
136 A tuple of 3 values *)
137 let tuple3 (one:lens) (two:lens) (three:lens) =
140 . [ label "value" . one ]
142 . [ label "value" . two ]
144 . [ label "value" . three ]
149 let list (kw:regexp) (lns:lens) =
157 A <list> of seq entries *)
158 let value_list (kw:regexp) (sto:lens) =
159 list kw (make_value sto)
161 (* View: application *)
162 let application (name:regexp) (parameter:lens) =
165 (* View: kernel_parameters
166 Config parameters accepted for kernel app *)
167 let kernel_parameters =
168 value "browser_cmd" path
169 | value "dist_auto_connect" (store /never|once/)
170 | value "error_logger" (store /tty|false|silent/)
171 | value "net_setuptime" integer
172 | value "net_ticktime" integer
173 | value "shutdown_timeout" integer
174 | value "sync_nodes_timeout" integer
175 | value "start_dist_ac" boolean
176 | value "start_boot_server" boolean
177 | value "start_disk_log" boolean
178 | value "start_pg2" boolean
179 | value "start_timer" boolean
182 Core Erlang kernel app configuration *)
183 let kernel = application "kernel" kernel_parameters
186 let comment = Util.comment_generic /%[ \t]*/ "% "
189 A top-level config *)
190 let config (app:lens) =
191 (Util.empty | comment)*
193 . Build.opt_list (kernel | app) (lrspace comma)
195 . Util.del_str "." . Util.eol
196 . (Util.empty | comment)*