<div dir="ltr"><br><br><div class="gmail_quote">On Thu, Aug 14, 2008 at 11:56 AM, Raphaël Pinson <span dir="ltr"><<a href="mailto:raphink@gmail.com">raphink@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Hi there,<br><br><br>As I'm playing with inifile.aug and applying it to php.aug, mysql.aug and dput.aug, I find so many different configurations that inifile.aug gets very complicated to my taste. Since functions in lenses cannot take defaults, I end up defining lots of them to set more or less variables. I would like to really simplify inifile.aug. This might mean making the lenses that use it a bit more complicated, but also clearer.<br>

<br>Here is my proposal. Comments are very welcome:<br><br>Writing a generic INI file using inifile.aug would look like this :<br><br>=========================================================<br>let comment_re      = /[;#]/<br>

let comment_default = ";"<br>let comment         = IniFile.comment comment_re comment_default<br><br>let empty           = IniFile.empty comment_re<br><br>let sep_re          = /[:=]/<br>let sep_default     = "="<br>

let sep             = IniFile.sep sep_re sep_default<br><br>(* IniFile.entry_re  = ( /[A-Za-z][A-Za-z0-9\._-]+/ - /#comment/ ) *)<br>let entry_re        = IniFile.entry_re<br>let entry            = IniFile.entry entry_re sep comment<br>

<br>(* IniFile.record_re = ( /[^]\n\/]+/ - /#comment/ ) *)<br>let record_re      = IniFile.record_re<br>let record          = IniFile.record record_re entry comment empty<br><br><br>let lns             = IniFile.lns record comment<br>

=========================================================<br><br><br>This would be a bit longer than it is currently, but much clearer, too.<br><br>The values taken by the setting fields would be:<br><br>comment_re        := ";"| "#" | /[;#]/<br>

comment_default := ";" | "#"<br><br>sep_re                 := ":" | "=" | /[:=]/<br>sep_default          := ";" | "="<br><br>entry_re               := IniFile.entry_re | your_own_re<br>

<br>record_re             := IniFile.record_re | your_own_re<br><br>Other values for these fields could not be certified to work properly.<br><br><br>Default values provided:<br><br>IniFile.comment_re        = /[;#]/<br>
IniFile.comment_default = ";"<br>
IniFile.sep_re                = /[:=]/<br>IniFile.sep_default         = "="<br>IniFile.entry_re              = ( /[A-Za-z][A-Za-z0-9\._-]+/ - /#comment/ )<br>IniFile.record_re            =  ( /[^]\n\/]+/ - /#comment/ ) <br>

<br><br>
Additionally, IniFile.record_noempty and IniFile.lns_noempty would be provided, since I don't know how to deal with these.<br>
<br><br>Another example, with dput.aug :<br><br>=========================================================<br><br>
let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default<br>
let empty      = IniFile.empty IniFile.comment_re<br>
<br>
let sep          = IniFile.sep IniFile.sep_re IniFile.set_default<br>
<br>let setting = "allow_non-us_software"<br>               | "allow_unsigned_uploads"<br>               | "check_version"<br>               | "default_host_main"<br>               | "default_host_non-us"<br>

               | "fqdn"<br>               | "hash"<br>               | "incoming"<br>               | "login"<br>               | "method"<br>               | "passive_ftp"<br>

               | "post_upload_command"<br>               | "pre_upload_command"<br>               | "progress_indicator"<br>               | "run_dinstall"<br>               | "run_lintian"<br>

               | "scp_compress"<br>               | "ssh_config_options"<br>
let entry = IniFile.entry setting sep comment<br>
<br>
let record  = IniFile.record IniFile.record_re entry comment empty<br>
<br>
let lns    = IniFile.lns record comment<br>
=========================================================<br><br><br>It is obviously longer than the current format, but also much clearer on what is accepted and what is not. Alternatively, this is php.aug:<br><br>
=========================================================<br><br>let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default<br>

let empty      = IniFile.empty IniFile.comment_re<br>let eol          = IniFile.eol<br><br>let sep          = IniFile.sep IniFile.sep_re IniFile.set_default<br><br>(*<br>  We have to remove the keyword "section" from possible entry keywords<br>

  otherwise it would lead to an ambiguity with the "section" label<br>  since PHP allows entries outside of sections.<br>*)<br>let entry_re  = (  /[A-Za-z][A-Za-z0-9\._-]+/ - /#comment/ - /section/ )<br>let entry = IniFile.entry entry_re sep comment<br>

<br>let title<br>           = label "section"<br>             .Util.del_str "[" . store /[^]]+/<br>             . Util.del_str "]". eol<br><br>let record = [ title_label<br>             . (entry | comment | empty)* ]<br>

<br>let lns    = ( comment | empty | entry )* . record*<br>
=========================================================<br><br></div></blockquote><div><br><br>Alternatively, PHP.lns could be<br><br>let lns = IniFile.lns record (comment|entry) <br><br>This trick would send (comment|entry) as the comment lens for IniFile.lns, so lns would be equivalent to:<br>
<br>let lns =  ( (comment|entry) | empty )* . record*<br><br><br><br>Raphaël<br></div></div><br><br></div>