<br><br><div class="gmail_quote">On Thu, Mar 7, 2013 at 4:33 PM, Serge Smetana <span dir="ltr"><<a href="mailto:serge.smetana@gmail.com" target="_blank">serge.smetana@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Raphaël,<br>
<br>
Trying to use Build.block_newlines construct<br>
<br>
   let any = Rx.no_spaces<br>
   let value = any . (Rx.space . any)*<br>
   let commands  = /include|include_try/<br>
   let block_names = /dict|userdb|passdb|protocol|service|plugin|namespace|map/<br>
   let nested_block_names =  /fields|unix_listener|fifo_listener|inet_listener/<br>
   let keys = Rx.word - commands - block_names - nested_block_names<br></blockquote><div><br>This kind of constructs makes augparse (and run) verrrrrrrrrrrrry slooooow. It is best to rewrite them as:<br><br>   let keys = Rx.word - (commands | block_names | nested_block_names)<br>
<br>which is strictly equivalent, but much faster.<br><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
   let entry = [ indent . key keys. eq . (Sep.opt_space . store value)? . eol ]<br>
   let command = [ command_start . key commands . Sep.space . store<br>
Rx.fspath . eol ]<br>
<br>
   let block_args   = Sep.space . store any<br>
<br>
   let nested_block = [ indent . key block_names . block_args? .<br>
Build.block_newlines entry comment . eol ]<br>
<div class="im">   let block = [ indent . key block_names . block_args? .<br>
</div>Build.block_newlines (entry|nested_block)* comment . eol]<br>
<br>
   let lns = (comment|empty|entry|command|block)*<br>
<br>
If I try to compile this I get an exception: ambiguous concatenation<br>
<br>
      First regexp: /([<br>
\t]*)(dict|userdb|passdb|protocol|service|plugin|namespace|map)((([<br>
\t]+)([^ \t\n]+))?)/<br>
      Second regexp: /([ \t\n]+\\{([ \t\n]*\n)?)((((([<br>
\t]*)((dict[.0-9A-Z_a-z-][.0-9A-Z_a-z-]| ...... <long regexp<br>
here>.....<br>
<br>
      'userdb {# {\n}' can be split into<br>
      'userdb|=| {# {\n}'<br>
<br>
     and<br>
      'userdb {#|=| {\n}'<br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I guess this is because of optional block_args? in lens definition.<br></blockquote><div><br><br>Yes, precisely. Spaces must belong only to one side of two concatenated expressions.<br><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

But my old variant without Build.block* construct works:<br>
<br>
  let block_open        = del /[ \t]*\{/ "{"<br>
  let block_close       = del /\}/ "}"<br>
<br>
  .... same as above<br>
<br>
  let nested_block =<br>
       [ indent . key nested_block_names . block_args? . block_open . eol<br>
<div class="im">       . (entry | empty | comment)*<br>
       . indent . block_close . eol ]<br>
<br>
   let block =<br>
       [ indent . key block_names . block_args? . block_open . eol<br>
</div>       . (entry | empty | comment | nested_block )*<br>
<div class="im HOEnZb">      . indent . block_close . eol ]<br></div></blockquote><div><br><br>Build.block_newlines allows things like<br><br>    unix_listener {# {\n}<br><br>where "# {\n" should be a comment.<br>
<br>However, block_args? allows *any* character (including "#" and "{") to be present between the key and the opening bracket. I think block_args should be refined to only allow the characters you need.<br>
<br><br>Regards,<br></div></div><br>-- <br>Raphaël Pinson<br>Administrateur Systèmes & Réseaux<br>
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>