Parses Trapperkeeper configuration files
Author: Raphael Pinson raphael.pinson@camptocamp.com
| Trapperkeeper | Parses Trapperkeeper configuration files |
| 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 Trapperkeeper webservice configuration files. |
| Examples | The <Test_Trapperkeeper> file contains various examples and tests. |
| USEFUL PRIMITIVES | |
| empty | |
| comment | |
| sep | |
| sep_with_spc | |
| BLOCKS (FROM 1. | |
| block_ldelim_newlines_re | |
| block_rdelim_newlines_re | |
| block_ldelim_newlines_default | |
| block_rdelim_newlines_default | |
| block_newline | A block enclosed in brackets, with newlines forced and indentation defaulting to a tab. |
| ENTRY TYPES | |
| simple | |
| array | |
| hash | |
| ENTRY | |
| entry | |
| LENS AND FILTER | |
| lns | |
| filter |
This lens applies to Trapperkeeper webservice configuration files. See filter.
let block_newlines (entry:lens) (comment:lens) = del block_ldelim_newlines_re block_ldelim_newlines_default . ((entry | comment) . (Util.empty | entry | comment)*)? . del block_rdelim_newlines_re block_rdelim_newlines_default
A block enclosed in brackets, with newlines forced and indentation defaulting to a tab.
| entry:lens | the entry to be stored inside the block. This entry should not include Util.empty, Util.comment or Util.comment_noindent, should be indented and finish with an eol. |
let empty = Util.empty
let comment = Util.comment
let sep = del /[ \t]*[:=]/ ":"
let sep_with_spc = sep . Sep.opt_space
let block_rdelim_newlines_re = /[ \t]*\}/
let block_rdelim_newlines_default = "}"
A block enclosed in brackets, with newlines forced and indentation defaulting to a tab.
let block_newlines (entry:lens) (comment:lens) = del block_ldelim_newlines_re block_ldelim_newlines_default . ((entry | comment) . (Util.empty | entry | comment)*)? . del block_rdelim_newlines_re block_rdelim_newlines_default
let array = let lbrack = Util.del_str "[" in let rbrack = Util.del_str "]" in let opt_space = del /[ \t]*/ "" in let comma = opt_space . Util.del_str "," . opt_space
let hash (lns:lens) = [ Util.indent . label "@hash" . store Rx.word . sep . block_newlines lns Util.comment . Util.eol ]
let rec entry = hash (entry|simple|array)
let lns = (empty|comment)* . (entry . (empty|comment)*)*
Map empty lines, including empty comments
let empty = empty_generic empty_generic_re
Map comments into “#comment” nodes
let comment = comment_generic /[ \t]*#[ \t]*/ "# "
Map comments into “#comment” nodes, without indentation
let comment_noindent = comment_generic /#[ \t]*/ "# "