<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">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>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">https://github.com/hercules-team/augeas/issues/138</a><br><br>[2] <a href="http://en.wikipedia.org/wiki/Ambiguous_grammar#Dangling_else">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">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">http://en.wikipedia.org/wiki/Maximal_munch</a><br>
<br></div></div></div></div>