Erlang

Parses Erlang configuration files

Author: Raphael Pinson raphael.nosp@m..pinson@camptoc.nosp@m.amp.com

Summary
ErlangParses Erlang configuration files
ReferenceThis lens tries to keep as close as possible to `http://www.erlang.org/doc/man/config.html` where possible.
LicenseThis file is licenced under the LGPL v2+, like the rest of Augeas.
Lens UsageTo be documented
Configuration filesThis lens applies to Erlang configuration files.
ExamplesThe Test_Erlang file contains various examples and tests.
Spacing Functions
space
lspaceAdd spaces to the left of char
rspaceAdd spaces to the right of char
lrspaceAdd spaces to the left or right of char
Separators
lbraceLeft square bracket
rbraceRight square bracket
lbrackLeft curly brackets
rbrackRight curly brackets
lglobLeft glob separator
rglobRight glob separator
comma
Value types
opt_listAn optional list of elements, in square brackets
integerStore a Rx.integer
decimalStore a decimal value
quotedStore a quoted value
bareStore a bare Rx.word
booleanStore a boolean value
pathStore a path (quoted)
globStore a glob
make_valueMake a “value” subnode for arrays/tuples
Store types
valueA single value
tupleA tuple of values
listA list of lenses
value_listA list of seq entries
application
kernel_parametersConfig parameters accepted for kernel app
kernelCore Erlang kernel app configuration
comment
configA top-level config

Reference

This lens tries to keep as close as possible to `http://www.erlang.org/doc/man/config.html` where possible.

License

This file is licenced under the LGPL v2+, like the rest of Augeas.

Lens Usage

To be documented

Configuration files

This lens applies to Erlang configuration files.  See filter.

Examples

The Test_Erlang file contains various examples and tests.

Spacing Functions

space

let space = del /[ \t\n]*/ ""

lspace

let lspace (char:string) = del (/[ \t\n]*/ . char) char

Add spaces to the left of char

rspace

let rspace (char:string) = del (char . /[ \t\n]*/ ) char

Add spaces to the right of char

lrspace

let lrspace (char:string) = del (/[ \t\n]*/ . char . /[ \t\n]*/ ) char

Add spaces to the left or right of char

Separators

lbrace

Left square bracket

rbrace

let rbrace = "}"

Right square bracket

lbrack

Left curly brackets

rbrack

let rbrack = "]"

Right curly brackets

lglob

Left glob separator

rglob

let rglob = "\">>"

Right glob separator

comma

let comma = ","

Value types

opt_list

let opt_list (lns:lens) = rspace lbrack . (Build.opt_list lns (lrspace comma) . space)? . Util.del_str rbrack

An optional list of elements, in square brackets

integer

let integer = store Rx.integer

Store a Rx.integer

decimal

let decimal = store /[0-9]+(.[0-9]+)?/

Store a decimal value

quoted

Store a quoted value

bare

let bare = store Rx.word

Store a bare Rx.word

boolean

let boolean = store /true|false/

Store a boolean value

path

let path = quoted

Store a path (quoted)

glob

let glob = Util.del_str lglob . store /[^\n"]+/ . Util.del_str rglob

Store a glob

make_value

let make_value (lns:lens) = [ label "value" . lns ]

Make a “value” subnode for arrays/tuples

Store types

value

let value (kw:regexp) (sto:lens) = [ rspace lbrace . key kw . lrspace comma . sto . lspace rbrace ]

A single value

tuple

let tuple (one:lens) (two:lens) = [ rspace lbrace . label "tuple" . [ label "value" . one ] . lrspace comma . [ label "value" . two ] . lspace rbrace ]

A tuple of values

list

let list (kw:regexp) (lns:lens) = [ rspace lbrace . key kw . lrspace comma . opt_list lns . lspace rbrace ]

A list of lenses

value_list

let value_list (kw:regexp) (sto:lens) = list kw (make_value sto)

A list of seq entries

application

let application (name:regexp) (parameter:lens) = list name parameter

kernel_parameters

let kernel_parameters = value "browser_cmd" path | value "dist_auto_connect" (store /never|once/) | value "error_logger" (store /tty|false|silent/) | value "net_setuptime" integer | value "net_ticktime" integer | value "shutdown_timeout" integer | value "sync_nodes_timeout" integer | value "start_dist_ac" boolean | value "start_boot_server" boolean | value "start_disk_log" boolean | value "start_pg2" boolean | value "start_timer" boolean

Config parameters accepted for kernel app

kernel

let kernel = application "kernel" kernel_parameters

Core Erlang kernel app configuration

comment

let comment = Util.comment_generic /%[ \t]*/ "% "

config

let config (app:lens) = (Util.empty | comment)* . rspace lbrack . Build.opt_list (kernel | app) (lrspace comma) . lrspace rbrack . Util.del_str "." . Util.eol . (Util.empty | comment)*

A top-level config

Provides unit tests and examples for the Erlang lens.
let space = del /[ \t\n]*/ ""
let lspace (char:string) = del (/[ \t\n]*/ . char) char
Add spaces to the left of char
let rspace (char:string) = del (char . /[ \t\n]*/ ) char
Add spaces to the right of char
let lrspace (char:string) = del (/[ \t\n]*/ . char . /[ \t\n]*/ ) char
Add spaces to the left or right of char
let rbrace = "}"
Right square bracket
let rbrack = "]"
Right curly brackets
let rglob = "\">>"
Right glob separator
let comma = ","
let opt_list (lns:lens) = rspace lbrack . (Build.opt_list lns (lrspace comma) . space)? . Util.del_str rbrack
An optional list of elements, in square brackets
let integer = store Rx.integer
Store a Rx.integer
let integer = /[0-9]+/
One or more digits
let decimal = store /[0-9]+(.[0-9]+)?/
Store a decimal value
let bare = store Rx.word
Store a bare Rx.word
let word = /[A-Za-z0-9_.-]+/
An alphanumeric string
let boolean = store /true|false/
Store a boolean value
let path = quoted
Store a path (quoted)
Store a quoted value
let glob = Util.del_str lglob . store /[^\n"]+/ . Util.del_str rglob
Store a glob
let make_value (lns:lens) = [ label "value" . lns ]
Make a “value” subnode for arrays/tuples
let value (kw:regexp) (sto:lens) = [ rspace lbrace . key kw . lrspace comma . sto . lspace rbrace ]
A single value
let tuple (one:lens) (two:lens) = [ rspace lbrace . label "tuple" . [ label "value" . one ] . lrspace comma . [ label "value" . two ] . lspace rbrace ]
A tuple of values
let list (kw:regexp) (lns:lens) = [ rspace lbrace . key kw . lrspace comma . opt_list lns . lspace rbrace ]
A list of lenses
let value_list (kw:regexp) (sto:lens) = list kw (make_value sto)
A list of seq entries
let application (name:regexp) (parameter:lens) = list name parameter
let kernel_parameters = value "browser_cmd" path | value "dist_auto_connect" (store /never|once/) | value "error_logger" (store /tty|false|silent/) | value "net_setuptime" integer | value "net_ticktime" integer | value "shutdown_timeout" integer | value "sync_nodes_timeout" integer | value "start_dist_ac" boolean | value "start_boot_server" boolean | value "start_disk_log" boolean | value "start_pg2" boolean | value "start_timer" boolean
Config parameters accepted for kernel app
let kernel = application "kernel" kernel_parameters
Core Erlang kernel app configuration
let comment = Util.comment_generic /%[ \t]*/ "% "
let config (app:lens) = (Util.empty | comment)* . rspace lbrack . Build.opt_list (kernel | app) (lrspace comma) . lrspace rbrack . Util.del_str "." . Util.eol . (Util.empty | comment)*
A top-level config
Close