<div dir="ltr">> Could you provide an example of a string that does not parse with the lens I provided, and the tree you expect the lens should produce from it?<br><br>Right, looks like I forget to reference the input case. Anyway, here it is [2]. The tree structure is self-explanatory - identical to the previous trees - the schema only changes what is considered a comment.<br>
<br>> That said, I personally prefer to map comments in the tree, if we're going to parse them anyway.<br><br>Personally I prefer comments to be excluded, however the idea is to only modify the comment function (del -> store) to toggle this behaviour. Unfortunately actually handling comments is more difficult, below I have a rough draft [1] (no comment function, no comment storing) but it produces an error I don't understand:<br>
<br>    [(first two lenses) and (third lens) in entry]:exception: overlapping lenses in tree union.put<br>    Example matched by both:  {  }<br><br>What does this mean? Literal braces ("{  }"), or two literal spaces ("  "), or just a null string ? <br>
<br>Regards, <br><br><br>[1] let option              = key /[A-Z_]+/<br>    let value               = Sep.colon . Sep.opt_space . store /[^] \t\n:]+/ . Sep.opt_space<br>    let values              = counter "value" . [ seq "value" . value ] +<br>
    let setting             = Util.del_str "[" . option . values . Util.del_str "]"<br>    let entry               =<br>        let not_setting     = Rx.space_in - ( lens_ctype setting . /.*/ )<br><br>
            (* doesn't start with a space   - starts with setting           - doesn't match the empty string *)<br>        in  [ setting . del /.*/ "" . del /\n/ "\n" ] |<br><br>            (* doesn't start with a space   - doesn't start with setting    - doesn't match the empty string *)<br>
            [ del not_setting "s" . del /[ \t]*/ "" . del /\n/ "\n" ] |<br><br>            (* starts with a space                                          - doesn't match the empty string *)<br>
            [ del /[ \t]/ " " . del /.*/ "" . del /\n/ "\n" ] |<br><br>            (*                                                              - matches the empty string *)<br>            [ del /\n/ "\n" ]<br>
    let lns                 = entry *<br><br><br>[2] "<br>Change this to turn sound off.<br><br>[SOUND:YES]<br>[FONT:curses_640x300.png]<br>[RESIZABLE:YES]You may disable window resizing if you wish.<br><br>[PRINT_MODE:2D]<br>
    Mode examples:<br>[SINGLE_BUFFER:NO]<br>[EMBARK_RECTANGLE:4:4]<br><br>Change these numbers to set the default weights for traffic designations.  If you make the last numbers too large, pathfinding might lag.<br>The format is (PATH_COST:<high>:<normal>:<low>:<restricted>).<br>
[PATH_COST:1:2:5:25][A_COMMENT:4:4]<br><br>[A_COMMENT:  ]<br><br>    [ANOTHER_COMMENT:10:1:5:50]<br>"<br><br></div>