[augeas-devel] [Interfaces] Draft lense

Raphaël Pinson raphink at gmail.com
Thu Aug 21 10:45:21 UTC 2008


On Thu, Aug 21, 2008 at 12:11 PM, Free Ekanayaka <free at 64studio.com> wrote:

> Hi Raphaël,
>
> |--==> Raphaël Pinson writes:
>
>   RP> The problem here is actually a bit more complicated than in
> bbhosts.aug. The
>  RP> problem is that you have single line entries and multi lines entries.
> While
>  RP> single line entries can be followed by comments or empty lines, multi
> lines
>  RP> entries cannot, because they include comments and empty lines.
>
>  RP> let s_entry = (blah|blih) . (comment|empty)*
>  RP> let m_entry = (bloh|bluh)
>
>  RP> let lns = (comment|empty)* .
>   RP>              (m_entry | s_entry)*
>
>  RP> The idea is this:
>  RP>    - the file can begin with any amount of comments and empty lines.
>  RP>    - the entries (what we really care about) can be single line
> entries
>  RP> (s_entry) or multi lines entries (m_entry).
>  RP>    - single line entries can be followed by any amount of comments and
> empty
>  RP> lines.
>  RP>    - multi lines entries cannot be followed by comments and empty
> lines
>  RP> immediately. There has to be a s_entry to reintroduce "standalone"
> comments
>  RP> and empty lines because m_entry entries include them.
>
>  RP> With this pattern, you do not need to deal with comments and empty
> lines
>  RP> within s_entry entries, only within m_entry.
>  RP> When I cannot fix a bit of code in a lens, I try to rethink the whole
>  RP> structure of the lens, going back to what the lens actually is.
>
> I'm impressed, very good analysis!
>
>  RP> Let's try and see in the code...
>
>  RP> ============ interfaces.aug ===============
>   >>
>  >>let auto    = [ array /(allow-)?auto/ "auto" . eol . (comment|empty)* ]
>
>
>   RP> let auto = [ array /(allow-)?auto/ "auto" . (comment|eol) ]
>
>  RP> This is sufficient to have auto entries with optional trailing
> comments
>
> For some reasons augeas refuses to compile such a declaration:
>
> lenses/interfaces.aug:27.3-.65:Failed to compile auto
> lenses/interfaces.aug:27.19-.63:exception: ambiguous concatenation
>       'auto\\\nA# A\n' can be split into
>      'auto\\\nA|=|# A\n'
>
>     and
>      'auto\\\nA# A|=|\n'
>
>     First lens: lenses/interfaces.aug:21.37-.100
>    Second lens: lenses/interfaces.aug:27.50-.62
>


Let's see...

The expected tree for 'auto\\\nA# A\n' is

{ "auto"
   { "1" = "A"
      { "comment" = "A" } } }

and this is what the first lens does alright (btw David if you read this, I
think it would be great if lens conflicts would print the tree generated by
the lenses, it would greatly help to understand the issue).
But it seems that a second lens does

{ "auto"
   { "1" = "A# A" } }

'#' is not a valid character in an iface name, but we have:

let value_to_spc = store /[^\\ \t\n]+/
let array (r:regexp) (t:string) = del r t . label t . counter t . [ spc .
seq t . value_to_spc ]+


See the issue? Just turning your value_to_spc in to a [^\\# \t\n] should fix
this.


Ciao

Raphaël
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080821/77e86be8/attachment.htm>


More information about the augeas-devel mailing list