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]*`/
21 (* lists values of the form ... val1 val2 val3 ... *)
22 let list(word:regexp) =
23 let list_value = store word in
25 [ label "value" . list_value ] .
26 [ del /[ \t\n]+/ " " . label "value" . list_value ]* . indent
29 (* handle single quoted lists *)
30 let squote_arr = [ label "quote" . store /'/ ]
31 . (list sqword)? . del /'/ "'"
33 (* similarly handle double qouted lists *)
34 let dquote_arr = [ label "quote" . store /"/ ]
35 . (list dqword)? . del /"/ "\""
37 (* handle unquoted single value *)
38 let unquot_val = [ label "quote" . store "" ]
39 . [ label "value" . store (uqword+ | bqword)]?
42 (* lens for key value pairs *)
43 let kv = [ key key_re . eq .
44 ( (squote_arr | dquote_arr) . comment_or_eol
48 let lns = ( comment | empty | kv )*
50 let filter = incl "/etc/sysconfig/bootloader"
51 . incl "/etc/sysconfig/kernel"
53 let xfm = transform lns filter
55 (* Local Variables: *)