|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Erlang
|
|
Packit Service |
a2ae7a |
Parses Erlang configuration files
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Raphael Pinson <raphael.pinson@camptocamp.com>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
This lens tries to keep as close as possible to `http://www.erlang.org/doc/man/config.html` where possible.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licenced under the LGPL v2+, like the rest of Augeas.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Lens Usage
|
|
Packit Service |
a2ae7a |
To be documented
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Configuration files
|
|
Packit Service |
a2ae7a |
This lens applies to Erlang configuration files. See <filter>.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Examples
|
|
Packit Service |
a2ae7a |
The <Test_Erlang> file contains various examples and tests.
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
module Erlang =
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Spacing Functions *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: space *)
|
|
Packit Service |
a2ae7a |
let space = del /[ \t\n]*/ ""
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: lspace
|
|
Packit Service |
a2ae7a |
Add spaces to the left of char *)
|
|
Packit Service |
a2ae7a |
let lspace (char:string) = del (/[ \t\n]*/ . char) char
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: rspace
|
|
Packit Service |
a2ae7a |
Add spaces to the right of char *)
|
|
Packit Service |
a2ae7a |
let rspace (char:string) = del (char . /[ \t\n]*/ ) char
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: lrspace
|
|
Packit Service |
a2ae7a |
Add spaces to the left or right of char *)
|
|
Packit Service |
a2ae7a |
let lrspace (char:string) = del (/[ \t\n]*/ . char . /[ \t\n]*/ ) char
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Separators *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: lbrace
|
|
Packit Service |
a2ae7a |
Left square bracket *)
|
|
Packit Service |
a2ae7a |
let lbrace = "{"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: rbrace
|
|
Packit Service |
a2ae7a |
Right square bracket *)
|
|
Packit Service |
a2ae7a |
let rbrace = "}"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: lbrack
|
|
Packit Service |
a2ae7a |
Left curly brackets *)
|
|
Packit Service |
a2ae7a |
let lbrack = "["
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: rbrack
|
|
Packit Service |
a2ae7a |
Right curly brackets *)
|
|
Packit Service |
a2ae7a |
let rbrack = "]"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: lglob
|
|
Packit Service |
a2ae7a |
Left glob separator *)
|
|
Packit Service |
a2ae7a |
let lglob = "<<\""
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: rglob
|
|
Packit Service |
a2ae7a |
Right glob separator *)
|
|
Packit Service |
a2ae7a |
let rglob = "\">>"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: comma *)
|
|
Packit Service |
a2ae7a |
let comma = ","
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Value types *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: opt_list
|
|
Packit Service |
a2ae7a |
An optional list of elements, in square brackets *)
|
|
Packit Service |
a2ae7a |
let opt_list (lns:lens) = rspace lbrack
|
|
Packit Service |
a2ae7a |
. (Build.opt_list lns (lrspace comma) . space)?
|
|
Packit Service |
a2ae7a |
. Util.del_str rbrack
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: integer
|
|
Packit Service |
a2ae7a |
Store a <Rx.integer> *)
|
|
Packit Service |
a2ae7a |
let integer = store Rx.integer
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: decimal
|
|
Packit Service |
a2ae7a |
Store a decimal value *)
|
|
Packit Service |
a2ae7a |
let decimal = store /[0-9]+(.[0-9]+)?/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: quoted
|
|
Packit Service |
a2ae7a |
Store a quoted value *)
|
|
Packit Service |
a2ae7a |
let quoted = Quote.do_quote (store /[^,\n}{]+/)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: bare
|
|
Packit Service |
a2ae7a |
Store a bare <Rx.word> *)
|
|
Packit Service |
a2ae7a |
let bare = store Rx.word
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: boolean
|
|
Packit Service |
a2ae7a |
Store a boolean value *)
|
|
Packit Service |
a2ae7a |
let boolean = store /true|false/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: path
|
|
Packit Service |
a2ae7a |
Store a path (<quoted>) *)
|
|
Packit Service |
a2ae7a |
let path = quoted
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: glob
|
|
Packit Service |
a2ae7a |
Store a glob *)
|
|
Packit Service |
a2ae7a |
let glob = Util.del_str lglob . store /[^\n"]+/ . Util.del_str rglob
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: make_value
|
|
Packit Service |
a2ae7a |
Make a "value" subnode for arrays/tuples *)
|
|
Packit Service |
a2ae7a |
let make_value (lns:lens) = [ label "value" . lns ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Store types *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: value
|
|
Packit Service |
a2ae7a |
A single value *)
|
|
Packit Service |
a2ae7a |
let value (kw:regexp) (sto:lens) =
|
|
Packit Service |
a2ae7a |
[ rspace lbrace
|
|
Packit Service |
a2ae7a |
. key kw
|
|
Packit Service |
a2ae7a |
. lrspace comma
|
|
Packit Service |
a2ae7a |
. sto
|
|
Packit Service |
a2ae7a |
. lspace rbrace ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: tuple
|
|
Packit Service |
a2ae7a |
A tuple of values *)
|
|
Packit Service |
a2ae7a |
let tuple (one:lens) (two:lens) =
|
|
Packit Service |
a2ae7a |
[ rspace lbrace
|
|
Packit Service |
a2ae7a |
. label "tuple"
|
|
Packit Service |
a2ae7a |
. [ label "value" . one ]
|
|
Packit Service |
a2ae7a |
. lrspace comma
|
|
Packit Service |
a2ae7a |
. [ label "value" . two ]
|
|
Packit Service |
a2ae7a |
. lspace rbrace ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: tuple3
|
|
Packit Service |
a2ae7a |
A tuple of 3 values *)
|
|
Packit Service |
a2ae7a |
let tuple3 (one:lens) (two:lens) (three:lens) =
|
|
Packit Service |
a2ae7a |
[ rspace lbrace
|
|
Packit Service |
a2ae7a |
. label "tuple"
|
|
Packit Service |
a2ae7a |
. [ label "value" . one ]
|
|
Packit Service |
a2ae7a |
. lrspace comma
|
|
Packit Service |
a2ae7a |
. [ label "value" . two ]
|
|
Packit Service |
a2ae7a |
. lrspace comma
|
|
Packit Service |
a2ae7a |
. [ label "value" . three ]
|
|
Packit Service |
a2ae7a |
. lspace rbrace ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: list
|
|
Packit Service |
a2ae7a |
A list of lenses *)
|
|
Packit Service |
a2ae7a |
let list (kw:regexp) (lns:lens) =
|
|
Packit Service |
a2ae7a |
[ rspace lbrace
|
|
Packit Service |
a2ae7a |
. key kw
|
|
Packit Service |
a2ae7a |
. lrspace comma
|
|
Packit Service |
a2ae7a |
. opt_list lns
|
|
Packit Service |
a2ae7a |
. lspace rbrace ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: value_list
|
|
Packit Service |
a2ae7a |
A <list> of seq entries *)
|
|
Packit Service |
a2ae7a |
let value_list (kw:regexp) (sto:lens) =
|
|
Packit Service |
a2ae7a |
list kw (make_value sto)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: application *)
|
|
Packit Service |
a2ae7a |
let application (name:regexp) (parameter:lens) =
|
|
Packit Service |
a2ae7a |
list name parameter
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: kernel_parameters
|
|
Packit Service |
a2ae7a |
Config parameters accepted for kernel app *)
|
|
Packit Service |
a2ae7a |
let kernel_parameters =
|
|
Packit Service |
a2ae7a |
value "browser_cmd" path
|
|
Packit Service |
a2ae7a |
| value "dist_auto_connect" (store /never|once/)
|
|
Packit Service |
a2ae7a |
| value "error_logger" (store /tty|false|silent/)
|
|
Packit Service |
a2ae7a |
| value "net_setuptime" integer
|
|
Packit Service |
a2ae7a |
| value "net_ticktime" integer
|
|
Packit Service |
a2ae7a |
| value "shutdown_timeout" integer
|
|
Packit Service |
a2ae7a |
| value "sync_nodes_timeout" integer
|
|
Packit Service |
a2ae7a |
| value "start_dist_ac" boolean
|
|
Packit Service |
a2ae7a |
| value "start_boot_server" boolean
|
|
Packit Service |
a2ae7a |
| value "start_disk_log" boolean
|
|
Packit Service |
a2ae7a |
| value "start_pg2" boolean
|
|
Packit Service |
a2ae7a |
| value "start_timer" boolean
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: kernel
|
|
Packit Service |
a2ae7a |
Core Erlang kernel app configuration *)
|
|
Packit Service |
a2ae7a |
let kernel = application "kernel" kernel_parameters
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: comment *)
|
|
Packit Service |
a2ae7a |
let comment = Util.comment_generic /%[ \t]*/ "% "
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: config
|
|
Packit Service |
a2ae7a |
A top-level config *)
|
|
Packit Service |
a2ae7a |
let config (app:lens) =
|
|
Packit Service |
a2ae7a |
(Util.empty | comment)*
|
|
Packit Service |
a2ae7a |
. rspace lbrack
|
|
Packit Service |
a2ae7a |
. Build.opt_list (kernel | app) (lrspace comma)
|
|
Packit Service |
a2ae7a |
. lrspace rbrack
|
|
Packit Service |
a2ae7a |
. Util.del_str "." . Util.eol
|
|
Packit Service |
a2ae7a |
. (Util.empty | comment)*
|