Created
March 20, 2014 16:45
-
-
Save raphink/9668315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Haproxy = | |
autoload xfm | |
(************************************************************************ | |
* Group: USEFUL PRIMITIVES | |
*************************************************************************) | |
(* Group: Separators *) | |
(* | |
Variable: eol | |
eol, inherited from <Util.eol> | |
*) | |
let eol = Util.eol | |
(* | |
Variable: del_ws_spc | |
Delete mandatory white space, inherited from <Util.del_ws_spc > | |
*) | |
let del_ws_spc = Util.del_ws_spc | |
(* | |
Variable: indent | |
Delete indentation, including leading whitespace, inherited from <Util.indent > | |
*) | |
let indent = Util.indent | |
(* | |
Variable: space | |
Space, inherited from <Sep.space> | |
*) | |
let space = Sep.space | |
(* Group: Generic primitives *) | |
(* | |
Variable: space_in_no_comment | |
Matches string not starting or ending with a space, tab or comment separator and not containing a comment separator or newline (emulates greediness), modified <Rx.space_in> | |
*) | |
let space_in_no_comment = /[^ \t\n][^#\n]*[^ \t\n#]|[^ \t\n]/ | |
(* Group: Stores *) | |
(* | |
Variable: space_in_store | |
space_in as store lens | |
*) | |
let space_in_no_comment_store = store space_in_no_comment | |
(* Group: Subnode Constructions *) | |
(* | |
Variable: comment_optional | |
A subnode for optional comment, inherited from <Util.comment_eol> | |
*) | |
let comment_optional = Util.comment_eol | |
(* | |
Variable: empty | |
An empty line, inherited from <Util.empty> | |
*) | |
let empty = Util.empty | |
let block_re = "global" | "default" | |
let key_re = Rx.word - block_re | |
(* let options_lxc = option_eol_equal_comment_optional_lxc ("utsname") *) | |
let simple_key_value_option = [ indent . (key key_re . del_ws_spc . space_in_no_comment_store) . eol ] | |
let flag = [ indent . key key_re . eol ] | |
(* Group: Entries *) | |
let block = [ indent . key block_re . eol | |
. (simple_key_value_option | flag)* ] | |
(* View: lns | |
The lxc_conf lens | |
*) | |
let lns = ( block | | |
empty | comment_optional ) * | |
let xfm = transform lns (incl "/etc/haproxy/haproxy.cfg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment