echo [args]
let echo = Build.key_value_line "echo" space (store word)
mailonchange has specific syntax
let email = [ Util.indent . key "mailonchange" . space . [ label "emailaddress" . store email_addr ] . space . [ label "threshold" . store number ] . eol ]
A simple email address entry
let email = [ indent . label "email" . sto_email_addr . comment_or_eol ]
let empty = Util.empty
let empty = Util.empty
An Util.empty
let empty = Util.empty
A C-style empty line
let empty = Util.empty_c_style
let empty = Util.empty
let empty = Util.empty
let empty = Util.empty
let empty = Util.empty
let empty = Util.empty
let empty = Util.empty
Map empty lines.
let empty = Util.empty
let empty = Util.empty
Comment are not allowed, even empty comments
let empty = Util.empty_generic Rx.opt_space
Empty line
let empty = empty_generic Rx.opt_space comment_re
Map empty lines
let empty = Util.empty
Map empty lines, including empty comments
let empty = [ del /#?[ \t]*\n/ "\n" ]
let empty = IniFile.empty
let empty = Util.empty
let empty = Util.empty
let empty = Util.empty
let empty = Util.empty
let empty = Util.empty
Map empty lines, including empty asterisk comments
let empty = [ del /[ \t]*\*?[ \t]*\n/ "\n" ]
An empty line or a non-indented empty comment
let empty = IniFile.empty_noindent
Map empty lines
let empty = [ del /[ \t]*#?[ \t]*\n/ "\n" ]
Map empty lines, including empty comments
let empty = empty_generic empty_generic_re
let empty = Util.empty
Map empty lines, including C-style empty comment
let empty_c_style = empty_generic /[ \t]*((\/\/)|(\/\*[ \t]*\*\/))?[ \t]*/
let empty_dos = empty_generic_dos /[ \t]*#?[ \t]*/
let empty_entry = Build.key_value_line Rx.word Sep.equal Quote.dquote_opt_nil
let empty_entry = Build.key_value_line Rx.word Sep.equal blank_val
Empty line, including empty comments
let empty_generic (indent:regexp) (comment_re:regexp) = Util.empty_generic_dos (indent . comment_re? . Rx.opt_space)
A generic definition of empty Map empty lines, including empty comments
let empty_generic (r:regexp) = [ del r "" . del_str "\n" ]
A generic definition of empty with dos newlines Map empty lines, including empty comments
let empty_generic_dos (r:regexp) = [ del r "" . del /\r?\n/ "\n" ]
Empty line, without indentation
let empty_noindent = empty_generic "" comment_re
let entries = Build.key_value_line ("Explanation"|"Package"|"Pin-Priority") colon (store Rx.space_in) | pin | Util.comment
entries are either comments/empty lines or entries
let entries = (empty | comment | entry)*
let entry = IniFile.indented_entry entry_re sep comment
A valid entry line Definition:
let entry = [ access . colon . user_list . (except user_list)? . colon . origin_list . (except origin_list)? . Util.eol ]
let entry = Build.key_value_line Rx.word Sep.space_equal Quote.any_opt
let entry = [ label "target" . store target . space . [ label "linkname" . store linkname . eol ] ]
An anacrontab entry
let entry = [ label "entry" . Util.indent . ( period | period_name ) . Sep.space . delay . Sep.space . job_identifier . Sep.space . store Rx.space_in . Util.eol ]
let entry = IniFile.entry Rx.word sep comment
An apt.conf entry, recursive
let rec entry_noeol = let value = Util.del_str "\"" . store /[^"\n]+/ . del /";?/ "\";" in let opt_eol = del /[ \t\n]*/ "\n" in let long_eol = del /[ \t]*\n+/ "\n" in let list_elem = [ opt_eol . label "@elem" . value ] in let eol_comment = del /([ \t\n]*\n)?/ "" . comment in [ key name_re . Sep.space . value ] | [ key name_re . del /[ \t\n]*\{/ " {" . ( (opt_eol . entry_noeol) | list_elem | eol_comment )* . del /[ \t\n]*\};?/ "\n};" ] | [ key name_re . Util.del_str "::" . entry_noeol ]
A single map entry from start to finish, including multi-mounts
let entry = [ seq "entry" . entry_mkey . Util.del_ws_tab . entry_options? . ( entry_locations | entry_multimounts ) . Util.eol ]
let entry = IniFile.indented_entry IniFile.entry_re sep comment
let entry = [ label "entry" . store no_semicolon . (semicol . field_no_colon "provider")? . colon . field_int "frequency" . colon . field_word "parameter" . colon . field_word "signal_source" . colon . field_int "symbol_rate" . colon . vpid . colon . apid . colon . tpid . colon . caid . colon . field_int "sid" . colon . field_int "nid" . colon . field_int "tid" . colon . field_int "rid" . eol ]
A crontab entry
let entry = [ label "entry" . indent . prefix? . ( time | schedule ) . sep_spc . user . sep_spc . store Rx.space_in . eol ]
Map simple “key = value” entries including “key =” entries with empty value.
let entry = [ indent . key keys. eq . (Sep.opt_space . store value)? . eol ]
let entry = [ label "bookmark" . store Rx.no_spaces . (Sep.space . [ label "label" . store Rx.space_in ])? . Util.eol ]
let entry = bool ("multi"|"nospoof"|"spoofalert"|"reorder") | bool_warn "spoof" | list "order" "order" | trim
let entry = [ seq "line" . daemon_list . (except daemon_list)? . colon . client_list . (except client_list)? . ( (colon . option)+ | (colon . shell_command)? ) . Util.eol ]
Generic INI File entry
let entry (kw:regexp) (sep:lens) (comment:lens) = entry_generic (key kw) sep comment_re comment
An inputrc mapping entry
let entry = let mapping = [ label "mapping" . store Rx.word ] in [ label "entry" . Util.del_str "\"" . store /[^" \t\n]+/ . Util.del_str "\":" . Sep.space . mapping . Util.eol ]
A known_hosts entry
let entry = let alias = [ label "alias" . store Rx.neg1 ] in [ Util.indent . seq "entry" . store Rx.neg1 . (Sep.comma . Build.opt_list alias Sep.comma)? . Sep.space . [ label "type" . store Rx.no_spaces ] . Sep.space . [ label "key" . store Rx.no_spaces ] . Util.eol ]
A generic entry for lens lns
let entry (kw:regexp) (lns:lens) = Build.key_value_line kw sep lns
let entry = alias | options | kv_line_command /install|remove/ | blacklist | config | softdep
let entry = Build.key_value_line Rx.word Sep.space_equal (store Rx.space_in)
Define the accepted entries, such as param for regular configuration files, and macro for resources.cfg .
let entry = param | macro
Network / netmask line
let entry = [ seq "network" . indent . [ label "network" . store Rx.ipv4 ] . sep . [ label "netmask" . store Rx.ipv4 ] . comment_or_eol ]
let entry = let alias = [ seq "alias" . store Rx.word ] in [ seq "network" . counter "alias" . [ label "name" . store Rx.word ] . [ Sep.space . label "number" . store ipv4 ] . [ Sep.space . label "aliases" . Build.opt_list alias Sep.space ]? . (Util.eol|Util.comment) ]
struct passwd
let entry = [ key username . colon . password . uid . gid . name . home . shell . eol ]
let entry = entry_gen number | entry_gen word_opt_quot | entry_gen word_quot (* anything else *)
let entry = let protocol = [ label "protocol" . store protoname ] in let number = [ label "number" . store Rx.integer ] in let alias = [ label "alias" . store protoname ] in [ seq "protocol" . protocol . Sep.space . number . (Sep.space . Build.opt_list alias Sep.space)? . Util.comment_or_eol ]
let entry = Build.key_value_line Rx.word Sep.equal (store Rx.space_in)
let entry = [ key "allow" . Sep.space . condition_list . Sep.space . by . Util.eol ]
let entry = nameserver | domain | search | sortlist | options | lookup | family
An entry contains selectors and an action
let entry = [ label "entry" . Syslog.selectors . Syslog.sep_tab . [ label "action" . action ] . Util.eol ]
An IniFile.entry, or description
let entry = IniFile.entry (IniFile.entry_re - "description") sep comment | description
let entry = [ key word . colon . [ label "password" . sto_to_col? . colon ] . common . eol ]
let entry = let some_value = Sep.space_equal . store to_comment_re
let entry = let username = [ label "username" . store Rx.no_spaces ] in let usernames = Build.opt_list username Sep.space in Build.key_value_line Rx.word Sep.space_equal usernames
let entry = let comma_list_re = "password-stores" in let space_list_re = "global-ignores" | "preserved-conflict-file-exts" in let std_re = /[^ \t\r\n\/=#]+/ - (comma_list_re | space_list_re) in entry_std | IniFile.entry_list_nocomment comma_list_re sep Rx.word Sep.comma | IniFile.entry_list_nocomment space_list_re sep Rx.no_spaces (del /(\r?\n)?[ \t]+/ " ")
One route
let entry = [ store subnet . del /[ \t]*via[ \t]*/ " via " . key router . Util.del_str "\n" ]
an entry contains selectors and an action
let entry = [ label "entry" . selectors . sep_tab . [ label "action" . action ] . eol ]
An IniFile.entry
let entry = entry_single | entry_multi | entry_command | entry_env | comment
let entry = [ seq "entry" . store key_re . Sep.equal . ( multi_entry | single_entry )? . Util.eol ]
let entry = Build.key_value_line Rx.word Sep.space_equal Quote.double_opt
Exec* flags “@” and “-”.
let entry_command_flags = let exit = [ label "ignoreexit" . Util.del_str "-" ] in let arg0 = [ label "arg0" . Util.del_str "@" ] in exit? . arg0?
Entry that takes a space separated set of ENV=value key/value pairs
let entry_env = let envkv (env_val:lens) = key env_key . Util.del_str "=" . env_val
Prototype for our various key=value lines, with optional comment
let entry_fn (kw:regexp) (val:lens) = [ key kw . sep . val . (eol_comment|eol) ]
Builder to construct entries
let entry_gen (lns:lens) = Util.indent . Build.key_value_line_comment Rx.word sep lns Util.comment_eol
A very generic INI File entry It allows to set the key lens (to set indentation or subnodes linked to the key) as well as the comment separator regexp, used to tune the store regexps.
let entry_generic (kw:lens) (sep:lens) (comment_re:regexp) (comment:lens) = entry_generic_nocomment kw sep comment_re comment | comment
An entry without a specific handler.
let entry_generic = [ indent . key generic_entry_re . sep_spc . store to_eol . eol ]
A very generic INI File entry, not including comments It allows to set the key lens (to set indentation or subnodes linked to the key) as well as the comment separator regexp, used to tune the store regexps.
let entry_generic_nocomment (kw:lens) (sep:lens) (comment_re:regexp) (comment:lens) = let bare_re_noquot = (/[^" \t\r\n]/ - comment_re) in let bare_re = (/[^\r\n]/ - comment_re)+ in let no_quot = /[^"\r\n]*/ in let bare = Quote.do_dquote_opt_nil (store (bare_re_noquot . (bare_re* . bare_re_noquot)?)) in let quoted = Quote.do_dquote (store (no_quot . comment_re+ . no_quot)) in [ kw . sep . (Sep.opt_space . bare)? . (comment|eol) ] | [ kw . sep . Sep.opt_space . quoted . (comment|eol) ]
Host component with optional weight of an entry location
let entry_host = [ label "host" . store hostname . ( Util.del_str "(" . [ label "weight" . store weight ] . Util.del_str ")" )? ]
This matches an entry which takes a single integer for an argument
let entry_int (canon:string) (re:regexp) = [ indent . del re canon . label canon . sep_spc . store int . eol ]
The key for an entry in the config file
let entry_key = Rx.word
Generic INI File list entry
let entry_list (kw:regexp) (sep:lens) (sto:regexp) (list_sep:lens) (comment:lens) = let list = counter "elem" . Build.opt_list [ seq "elem" . store sto ] list_sep in Build.key_value_line_comment kw sep (Sep.opt_space . list) comment
Generic INI File list entry without an end-of-line comment
let entry_list_nocomment (kw:regexp) (sep:lens) (sto:regexp) (list_sep:lens) = let list = counter "elem" . Build.opt_list [ seq "elem" . store sto ] list_sep in Build.key_value_line kw sep (Sep.opt_space . list)
A single location with one or more hosts, and one path
let entry_location = ( entry_host . ( Sep.comma . entry_host )* )? . Sep.colon . entry_path
Multiple locations (each with one or more hosts), separated by spaces
let entry_locations = [ label "location" . counter "location" . [ seq "location" . entry_location ] . ( [ Util.del_ws_spc . seq "location" . entry_location ] )* ]
Generic multiline INI File entry
let entry_multiline (kw:regexp) (sep:lens) (comment:lens) = entry_multiline_generic (key kw) sep comment_re comment (comment|eol)
A very generic multiline INI File entry It allows to set the key lens (to set indentation or subnodes linked to the key) as well as the comment separator regexp, used to tune the store regexps.
let entry_multiline_generic (kw:lens) (sep:lens) (comment_re:regexp) (comment:lens) (eol:lens) = let newline = /\r?\n[ \t]+/ in let bare = let word_re_noquot = (/[^" \t\r\n]/ - comment_re)+ in let word_re = (/[^\r\n]/ - comment_re)+ in let base_re = (word_re_noquot . (word_re* . word_re_noquot)?) in let sto_re = base_re . (newline . base_re)* | (newline . base_re)+ in Quote.do_dquote_opt_nil (store sto_re) in let quoted = let no_quot = /[^"\r\n]*/ in let base_re = (no_quot . comment_re+ . no_quot) in let sto_re = base_re . (newline . base_re)* | (newline . base_re)+ in Quote.do_dquote (store sto_re) in [ kw . sep . (Sep.opt_space . bare)? . eol ] | [ kw . sep . Sep.opt_space . quoted . eol ] | comment
Generic multiline INI File entry without an end-of-line comment
let entry_multiline_nocomment (kw:regexp) (sep:lens) (comment:lens) = entry_multiline_generic (key kw) sep comment_re comment eol
Parses one of many mountpoints given for a multimount line
let entry_multimount = entry_mkey . Util.del_ws_tab . entry_options? . entry_locations
Separator for multimount entries, permits line spanning with “\”
let entry_multimount_sep = del /[ \t]+(\\\\[ \t]*\n[ \t]+)?/ " "
Parses multiple mountpoints given on an entry line
let entry_multimounts = [ label "mount" . counter "mount" . [ seq "mount" . entry_multimount ] . ( [ entry_multimount_sep . seq "mount" . entry_multimount ] )* ]
let entry_options = Util.del_str "-" . comma_sep_list "opt" . Util.del_ws_tab
let entry_or_comment = entry | comment
Path component of an entry location
let entry_path = [ label "path" . store path ]
This matches an entry which takes 3 integers as arguments representing red, green and blue components
let entry_rgb (canon:string) (re:regexp) = [ indent . del re canon . label canon . [ label "red" . sep_spc . store int ] . [ label "green" . sep_spc . store int ] . [ label "blue" . sep_spc . store int ] . eol ]
Entry that takes a single value containing spaces
let entry_single = entry_fn entry_single_kw [ label "value" . sto_value_single ]?
A standard entry Similar to a IniFile.entry_multiline_nocomment entry, but allows ‘;’
let entry_std = IniFile.entry_multiline_generic (key std_re) sep "#" comment IniFile.eol
Store a regexp as entry value
let entry_sto (kw:regexp) (val:regexp) = entry kw (store val)
This matches an entry which takes a single quoted string
let entry_str (canon:string) (re:regexp) = [ indent . del re canon . label canon . sep_spc . quoted_string_val . eol ]
The value for an entry may contain all sorts of things
let entry_value = /[A-Za-z0-9_.-:%]+/
Store a value that doesn’t contain spaces
let entry_value = [ label "value" . sto_value ]
This matches an entry which takes 2 integers as arguments representing X and Y coordinates
let entry_xy (canon:string) (re:regexp) = [ indent . del re canon . label canon . [ label "x" . sep_spc . store int ] . [ label "y" . sep_spc . store int ] . eol ]
let eol = Util.eol
let eol = Util.eol
And Util.eol end of line
let eol = Util.eol
let eol = Util.del_str "\n"
let eol = Util.eol
let eol = Util.eol
let eol = Util.eol
let eol = Util.eol
let eol = Util.eol
let eol = Util.eol
let eol = Util.eol
let eol = Util.eol
let eol = Util.eol
Only eol, don’t include whitespace
let eol = Util.del_str "\n"
let eol = Util.eol
let eol = Util.eol
let eol = Util.eol
let eq = del /[ \t]*=/ " ="
let eq = dels "="
let equal = Sep.equal
let equal = Sep.equal
The except operator makes it possible to write very compact rules.
let except (lns:lens) = [ label "except" . Sep.space . del /[Ee][Xx][Cc][Ee][Pp][Tt]/ "EXCEPT" . Sep.space . lns ]
The except operator makes it possible to write very compact rules.
let except (lns:lens) = [ label "except" . Sep.space . del /except/i "EXCEPT" . Sep.space . lns ]