[augeas-devel] Iterated lens leads to 'ambiguous tree iteration'

Štěpán Balážik stepan.balazik at nic.cz
Wed Mar 22 10:10:49 UTC 2017


Hi Xavier,

I suppose the 'eol' lens isn't named very descriptively since I need it 
to match:

* whitespace at the end of line
* comment at the end of the line
* all 'comment only' lines
* all empty (or whitespace) only lines

So if I had a text:

     blahblah #comment1
     #comment2

     #comment3

     blahblah

I need the lens to match everything marked between asterisks:

     blahblah* #comment1
     #comment2

     #comment3

     *blahblah


Yes, I'm trying to match both ; and # comments.

I couldn't get the lens with Util.comment_generic, so I tried to write 
it myself, which I found a bit easier to debug.

Also ws is just 'del [\t ]* ""'.

I would still appreciate at least a bit of insight into what is augparse 
trying to say by the exception.


Thanks for help,

Štěpán

On 03/22/2017 08:47 AM, Mol, Xavier (SCC) wrote:
> Hi Štěpán,
>
> I guess, you should not try to match the line break twice. So something similar to the following (which I have not verified to work properly) might work better:
>
> let eol = ws* . [ label "#comment" . del /[;#]/ ";" . store /[^\n]*/ ]? . del_str "\n"
>
>
> Furthermore, I guess that you try to match for comments with a ';' as well as '#', right? Then maybe you could try to use the Util.comment_generic lens, which allows you redefine the #comment node with a different regular expression?
>
> Ciao,
> Xavier.
>
>> -----Original Message-----
>> From: augeas-devel-bounces at redhat.com [mailto:augeas-devel-bounces at redhat.com] On Behalf Of Štepán Balážik
>> Sent: Tuesday, March 21, 2017 6:16 PM
>> To: augeas-devel at redhat.com
>> Subject: [augeas-devel] Iterated lens leads to 'ambiguous tree iteration'
>>
>> Hi,
>>
>> While writing a lens for Deckard tests
>> (https://gitlab.labs.nic.cz/knot/deckard) I ran into a problem.
>>
>> This lens
>>
>>       let eol = ws . ((del /[;#]/ ";" . [label "#comment" . store /[^\n]*/]
>>                 . del_str "\n") | (del_str "\n"))* . del_str "\n"
>>
>> results in this error:
>>
>>       $ augparse /usr/share/augeas/lenses/dist/deckard.aug
>>       Syntax error in lens definition
>>       /usr/share/augeas/lenses/dist/deckard.aug:22.0-.119:Failed to
>> compile eol
>> /usr/share/augeas/lenses/dist/deckard.aug:22.15-.104:exception:
>> ambiguous tree iteration
>>         Iterated regexp: /     { /#comment/ = /[^\001-\004\n]*/ }
>>         | ()/
>>         ' { "#comment" }' can be split into
>>         '|=| { "#comment" }'
>>
>>        and
>>         ' { "#comment" }|=|'
>>
>>       Iterated lens: /usr/share/augeas/lenses/dist/deckard.aug:22.15-.102:
>>
>> I can't get my head around the notation of Augeas' `tree -> plaintext`
>> exception notation so I have no idea what is `augparse` trying to say.
>>
>> Can anyone help me with an explanation or a fix for the lens?
>>
>> Thanks for tips and help,
>>
>> Štěpán
>>
>> _______________________________________________
>> augeas-devel mailing list
>> augeas-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/augeas-devel




More information about the augeas-devel mailing list