[augeas-devel] [Interfaces] Draft lense

Free Ekanayaka free at 64studio.com
Thu Aug 21 10:11:37 UTC 2008


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

Note that this happen even if I remove all other declaration (iface,
mapping, hotplug, m_entry, s_entry) and leave only:

let lns = ( comment | empty )*

without actually using the auto declaration.

Thanks,

Free




More information about the augeas-devel mailing list