[augeas-devel] Unions matching empty strings?

Matthew Palmer matt at anchor.net.au
Sat Aug 1 00:49:48 UTC 2009


On Fri, Jul 31, 2009 at 11:52:55AM +0200, David Lutterkort wrote:
> On Thu, 2009-07-30 at 08:45 +1000, Matthew Palmer wrote:
> > module Testparse =                                                                                                                                                                                              
> >         autoload xfm                                                                                                                                                                                            
> > 
> >         let option = [ (del /[Ff][Oo][Oo]/ "foo" . label "foo")
> >                       |(del /[Bb][Aa][Rr]/ "bar" . label "bar")
> >                       . del /[ \t]+/ " "
> >                       . store /[^ \t].*/
> >                       . del /\n/ "\n"
> >                      ]
> > 
> >         let lns = option+
> > 
> >         let filter = incl "/tmp/minparse"
> > 
> >         let xfm = transform lns filter
> > 
> > But I'm getting a rather arse error message:
> > 
> > ../testparse.aug:4.1-9.15:Failed to compile option
> > ../testparse.aug:4.16-8.30:exception: overlapping lenses in tree union.put
> >     Example matched by both: ''
> >     First lens: ../testparse.aug:4.16-.55
> >     Second lens: ../testparse.aug:5.15-8.30
> 
> You can work around it by using two separate '[]' constructs for the two
> branches of the union. Replacing option in the above with
> 
>         let option =
>           let value =
>             del /[ \t]+/ " " . store /[^ \t].*/ . del /\n/ "\n" in
>           [ del /[Ff][Oo][Oo]/ "foo" . label "foo" . value ]
>           | [ del /[Bb][Aa][Rr]/ "bar" . label "bar" . value ]
>         
> typechecks and should do what you want.

It most certainly does.  It was even relatively painless to do all the
options through the magic of search-n-replace.

> As a sidenote, case-insensitive
> regexps are something that's in dire need of being added to let you
> write 'del /foo/i "foo" ...'

That would have made my life a lot easier (and the lens a lot more
readable), it must be said.  Now I'm wondering how hard that'd be, and
whether I can squeeze it into my afternoon...

Lens submission in 3... 2... 1...

- Matt

-- 
"I have a cat, so I know that when she digs her very sharp claws into my
chest or stomach it's really a sign of affection, but I don't see any reason
for programming languages to show affection with pain."
		-- Erik Naggum, comp.lang.lisp




More information about the augeas-devel mailing list