<div dir="ltr">I see. How about:<div><br></div><div>=============================<br></div><div><div><div style="font-size:13px;font-family:arial,sans-serif">(* foo.aug *)</div></div><div>module Foo =</div><div><br></div><div>
let eol = del /[ \t]*\n/ "\n"</div><div><br></div><div>let empty = [ del /[ \t]*\n/ "\n" ]</div><div><br></div><div>let comment =</div><div>     let entry_rx = /\[[A-Z_]+:[ \t]*[^]\n \t]+\].*/</div><div>
  in let space_in = /[^ \r\t\n].*[^ \r\t\n]|[^ \t\n\r]/</div><div>  in [ Util.indent . label "#comment" . store (space_in - entry_rx) . eol ]</div><div><br></div><div>let entry =</div><div>   let value = [ seq "value" . Sep.colon . store /[^] \t\n:]+/ ]</div>
<div>   in [ Util.indent . Util.del_str "["</div><div>      . key /[A-Z_]+/ . counter "value" . value+</div><div>      . Util.del_str "]" . (comment|eol) ]</div><div><br></div><div>let lns = (empty|comment|entry)*</div>
<div><br></div><div><br></div><div>let conf = "Change this to turn sound off.</div><div><br></div><div>[SOUND:YES]</div><div>[FONT:curses_640x300.png]</div><div>[RESIZABLE:YES]You may disable window resizing if you wish.</div>
<div><br></div><div>[PRINT_MODE:2D]</div><div>    Mode examples:</div><div>[SINGLE_BUFFER:NO]</div><div>[EMBARK_RECTANGLE:4:4]</div><div><br></div><div>Change these numbers to set the default weights for traffic designations.  If you make the last numbers too large, pathfinding might lag.</div>
<div>The format is (PATH_COST:<high>:<normal>:<low>:<restricted>).</div><div>[PATH_COST:1:2:5:25][SOME_COMMENT: ]</div><div><br></div><div>[A_COMMENT:]\n"</div><div><br></div><div>test lns get conf = ?</div>
</div><div>=============================</div><div><div><div>Test result: foo.aug:38.0-.21:</div><div>  { "#comment" = "Change this to turn sound off." }</div><div>  {  }</div><div>  { "SOUND"</div>
<div>    { "1" = "YES" }</div><div>  }</div><div>  { "FONT"</div><div>    { "1" = "curses_640x300.png" }</div><div>  }</div><div>  { "RESIZABLE"</div><div>    { "1" = "YES" }</div>
<div>    { "#comment" = "You may disable window resizing if you wish." }</div><div>  }</div><div>  {  }</div><div>  { "PRINT_MODE"</div><div>    { "1" = "2D" }</div><div>  }</div>
<div>  { "#comment" = "Mode examples:" }</div><div>  { "SINGLE_BUFFER"</div><div>    { "1" = "NO" }</div><div>  }</div><div>  { "EMBARK_RECTANGLE"</div><div>    { "1" = "4" }</div>
<div>    { "2" = "4" }</div><div>  }</div><div>  {  }</div><div>  { "#comment" = "Change these numbers to set the default weights for traffic designations.  If you make the last numbers too large, pathfinding might lag." }</div>
<div>  { "#comment" = "The format is (PATH_COST:<high>:<normal>:<low>:<restricted>)." }</div><div>  { "PATH_COST"</div><div>    { "1" = "1" }</div>
<div>    { "2" = "2" }</div><div>    { "3" = "5" }</div><div>    { "4" = "25" }</div><div>    { "#comment" = "[SOME_COMMENT: ]" }</div><div>  }</div>
<div>  {  }</div><div>  { "#comment" = "[A_COMMENT:]" }</div></div><div style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial;font-size:small">=============================</span><br>
</div><div><div><br></div><div><div></div></div></div><div style="font-family:arial,sans-serif;font-size:13px"></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 26, 2014 at 5:59 PM, Yclept Nemo <span dir="ltr"><<a href="mailto:orbisvicis@gmail.com" target="_blank">orbisvicis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Thu, Jun 26, 2014 at 2:46 AM, Raphaël Pinson <span dir="ltr"><<a href="mailto:raphael.pinson@camptocamp.com" target="_blank">raphael.pinson@camptocamp.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div><br></div><div>I'm not sure if you're reporting a bug (in which case it would help to file it on the bugtracker [0]) or asking for help. I'll suppose the latter.</div>

<div>
<br></div><div>Here is a lens that parses your example. I suppose there must still be an issue (which is linked to the restrictions I had to put in the comment regexp —no "[" allowed as first character— but your example doesn't expose it then:</div>

</div></blockquote><div><br></div></div><div>Hi,<br><br></div><div>You're right - there are additional restrictions which I failed to demonstrate in the unit test, though I expressed them in the lenses (which compared from you examples had other shortcomings, ie not resetting the counter).<br>

<br>let comments="<br>[A_COMMENT:   ] <-- this is a comment<br>[NOT_A_COMMENT: 5 : 6 ][A_COMMENT:  ] <--- only the last [] is a comment<br>"<br><br>Since this is my first lens (just started using Augeas) I was seeking confirmation that this particular grammar is very difficult to express in Augeas, and if so hoping to prompt further development by some suggestions. I had just opened a github issue (#138, [1]) after posting this thread, with alternative solutions in addition to the original proposal of greedy operators.<br>

<br>For the record, I believe this is a common problem parsers face, (dangling-else, [2]), something parsing expression grammars [3] do not suffer, which can be solved, among other strategies, by "maximal munch" (greedy) [4].<br>

<br><br><br>[1] <a href="https://github.com/hercules-team/augeas/issues/138" target="_blank">https://github.com/hercules-team/augeas/issues/138</a><br><br>[2] <a href="http://en.wikipedia.org/wiki/Ambiguous_grammar#Dangling_else" target="_blank">http://en.wikipedia.org/wiki/Ambiguous_grammar#Dangling_else</a><br>

[3] <a href="http://stackoverflow.com/questions/1044600/difference-between-an-ll-and-recursive-descent-parser" target="_blank">http://stackoverflow.com/questions/1044600/difference-between-an-ll-and-recursive-descent-parser</a><br>
[4] <a href="http://en.wikipedia.org/wiki/Maximal_munch" target="_blank">http://en.wikipedia.org/wiki/Maximal_munch</a><br>
<br></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Raphaël Pinson<div>Infrastructure Developer & Trainer</div><div>+33 479 26 57 93<div>+33 781 90 00 79</div><div><br></div><div>Camptocamp France<br>

Savoie Technolac<br>
BP 352<br>
48, avenue du Lac du Bourget<br>
73372 Le Bourget du Lac, Cedex<br>
<a href="http://www.camptocamp.com" target="_blank">www.camptocamp.com</a><br>
</div></div></div>
</div>