Parses Erlang configuration files
Author: Raphael Pinson raphael@camptoc amp.com .pinson
Erlang | Parses Erlang configuration files |
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. |
Examples | The Test_Erlang file contains various examples and tests. |
Spacing Functions | |
lspace | Add spaces to the left of char |
rspace | Add spaces to the right of char |
lrspace | Add spaces to the left or right of char |
Separators | |
lbrace | Left square bracket |
rbrace | Right square bracket |
lbrack | Left curly brackets |
rbrack | Right curly brackets |
lglob | Left glob separator |
rglob | Right glob separator |
comma | |
Value types | |
opt_list | An optional list of elements, in square brackets |
integer | Store a Rx.integer |
decimal | Store a decimal value |
quoted | Store a quoted value |
bare | Store a bare Rx.word |
boolean | Store a boolean value |
path | Store a path (quoted) |
glob | Store a glob |
make_value | Make a “value” subnode for arrays/tuples |
Store types | |
value | A single value |
value | A tuple of values |
list | A list of lenses |
value_list | A list of seq entries |
application | |
comment | |
config | A top-level config |
This lens tries to keep as close as possible to `http://www.erlang.org/doc/man/config.html` where possible.
This lens applies to Erlang configuration files. See filter.
The Test_Erlang file contains various examples and tests.
let integer = store Rx.integer
Store a Rx.integer
let bare = store Rx.word
Store a bare Rx.word
let path = quoted
Store a path (quoted)
let value_list (kw:regexp) (sto:lens) = list kw (make_value sto)
A list of seq entries
Add spaces to the left of char
let lspace (char:string) = del (/[ \t\n]*/ . char) char
Add spaces to the right of char
let rspace (char:string) = del (char . /[ \t\n]*/ ) char
Add spaces to the left or right of char
let lrspace (char:string) = del (/[ \t\n]*/ . char . /[ \t\n]*/ ) char
Right square bracket
let rbrace = "}"
Right curly brackets
let rbrack = "]"
Right glob separator
let rglob = "\">>"
let comma = ","
An optional list of elements, in square brackets
let opt_list (lns:lens) = rspace lbrack . Build.opt_list lns (lrspace comma) . lspace rbrack
Store a Rx.integer
let integer = store Rx.integer
One or more digits
let integer = /[0-9]+/
Store a decimal value
let decimal = store /[0-9]+(.[0-9]+)?/
Store a bare Rx.word
let bare = store Rx.word
An alphanumeric string
let word = /[A-Za-z0-9_.-]+/
Store a boolean value
let boolean = store /true|false/
Store a path (quoted)
let path = quoted
Store a glob
let glob = Util.del_str lglob . store /[^\n"]+/ . Util.del_str rglob
Make a “value” subnode for arrays/tuples
let make_value (lns:lens) = [ label "value" . lns ]
A single value
let value (kw:regexp) (sto:lens) = [ rspace lbrace . key kw . lrspace comma . sto . lspace rbrace ]
A list of lenses
let list (kw:regexp) (lns:lens) = [ rspace lbrace . key kw . lrspace comma . opt_list lns . lspace rbrace ]
A list of seq entries
let value_list (kw:regexp) (sto:lens) = list kw (make_value sto)
let application (name:regexp) (parameter:lens) = list name parameter
let comment = Util.comment_generic /%[ \t]*/ "% "
A top-level config
let config (app:lens) = (Util.empty | comment)* . rspace lbrack . Build.opt_list app (lrspace comma) . lrspace rbrack . Util.del_str "." . Util.eol . (Util.empty | comment)*