[augeas-devel] About abstract type

David Lutterkort lutter at redhat.com
Tue Apr 20 19:04:36 UTC 2010


On Tue, 2010-04-20 at 13:04 -0400, Francis Giraldeau wrote:
> Hi,
> 
> I'm trying to get more debug info about lenses, and something is not
> clear. Let be the following lens, to parse a simple line with numbers
> and letters. Letters chunks are keept under their own subtree.
> 
> let a = [ key /[0-9]+/ . [ del /[ ]+/ " " . key /[a-z]+/ ]* .
>           del "\n" "\n" ]
> 
> The string "1 a b c\n2 d e f\n" generates the tree :
> 
>   { "1"
>     { "a" }
>     { "b" }
>     { "c" }
>   }
>   { "2"
>     { "d" }
>     { "e" }
>     { "f" }
>   }
> 
> But, the abstract type of the lens looks like this :
> 
> { /[0-9]+/ }
> 
> which doesn't match children of "number" nodes. Here is what I would
> have expected :
> 
> { /0-9+/ { /a-z/+ }* }
> 
> Otherwise, we never have access to inner node abstract type, isn't?

The dirty secret is that Augeas finds its way through a tree by looking
at one level of nodes in the tree at a time, in a way it's a very eager
top-down tree automaton.

So, when Augeas does a put on your example tree above, it first looks
only at the sequence of nodes { "1" } { "2" } and uses the atype of the
toplevel lens to match them. Based on that match, it then transforms the
children of "1", i.e. the sequence { "a" } { "b" } { "c" } using the
atype of whatever lens it decided to use based on the fact that it went
down into the "1" branch of the tree. The same happens for the "2" node.

It would be nice to enhance Augeas to do a match on the full tree, but I
haven't had the time to do that, and the current somewhat limited scheme
seems to work good enough.

David





More information about the augeas-devel mailing list