1 (* Generic lens for shell-script config files like the ones found *)
2 (* in /etc/sysconfig, where a string needs to be split into *)
4 module Shellvars_list =
9 let key_re = /[A-Za-z0-9_]+/
10 let eq = Util.del_str "="
11 let comment = Util.comment
12 let comment_or_eol = Util.comment_or_eol
13 let empty = Util.empty
14 let indent = Util.indent
16 let sqword = /[^ '\t\n]+/
17 let dqword = /([^ "\\\t\n]|\\\\.)+/
18 let uqword = /([^ `"'\\\t\n]|\\\\.)+/
19 let bqword = /`[^`\n]*`/
20 let space_or_nl = /[ \t\n]+/
21 let space_or_cl = space_or_nl | Rx.cl
23 (* lists values of the form ... val1 val2 val3 ... *)
24 let list (word:regexp) (sep:regexp) =
25 let list_value = store word in
27 [ label "value" . list_value ] .
28 [ del sep " " . label "value" . list_value ]* . indent
31 (* handle single quoted lists *)
32 let squote_arr = [ label "quote" . store /'/ ]
33 . (list sqword space_or_nl)? . del /'/ "'"
35 (* similarly handle double qouted lists *)
36 let dquote_arr = [ label "quote" . store /"/ ]
37 . (list dqword space_or_cl)? . del /"/ "\""
39 (* handle unquoted single value *)
40 let unquot_val = [ label "quote" . store "" ]
41 . [ label "value" . store (uqword+ | bqword)]?
44 (* lens for key value pairs *)
45 let kv = [ key key_re . eq .
46 ( (squote_arr | dquote_arr) . comment_or_eol
50 let lns = ( comment | empty | kv )*
52 let filter = incl "/etc/sysconfig/bootloader"
53 . incl "/etc/sysconfig/kernel"
55 let xfm = transform lns filter
57 (* Local Variables: *)