[augeas-devel] how to make lens accept both quoted and unquoted values with trailing comments

Raphaël Pinson raphael.pinson at camptocamp.com
Wed Nov 12 12:37:48 UTC 2014


Hi,

The best way to process these now is to use the Quote module, which makes
use of square lenses. There's quite a few examples using it already.


Raphaël


On Tue, Nov 11, 2014 at 5:04 PM, Timur Batyrshin <erthad at gmail.com> wrote:

> Hi all,
>
> I'm trying to create a lens that accepts both quoted and unquoted values
> and is able to process trailing comments of both ; and #-style
>
> Here is my lens (actually it is only a part of bigger pre-1.1
> inifile-based one but this is enough to reproduce the issue):
>
> module Testtest =
>
> let to_comment_re = /[^";# \t\n][^;#\n]*[^;# \t\n]|[^";# \t\n]/
> let sto_to_comment = Sep.opt_space . store to_comment_re
>
> let quote = del "\"" "\""
> let quoted_value_re = /[^"]*/
> let quoted_value = Sep.opt_space . (quote . (store quoted_value_re) .
> quote)
>
> let value = sto_to_comment | quoted_value
>
>
> When I try to process it with augparse I see the following result:
>
> $ augparse /tmp/testtest.aug
> Syntax error in lens definition
> /tmp/testtest.aug:10.0-.41:Failed to compile value
> /tmp/testtest.aug:10.12-.41:exception: overlapping lenses in tree union.put
>     Example matched by both:
>     First lens: /tmp/testtest.aug:4.21-.56:
>     Second lens: /tmp/testtest.aug:8.19-.76:
>
> How should I deal with errors like that?
> I understand that augeas can't figure out if it should quote my value or
> not when writing it but I have no ideas how to make it separate between
> them.
> How do you usually handle the case like this one?
>
>
> Thanks,
> Timur
>
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel
>



-- 
Raphaël Pinson
Infrastructure Developer & Training Leader
+33 479 26 57 93
+33 781 90 00 79

Camptocamp France
Savoie Technolac
BP 352
48, avenue du Lac du Bourget
73372 Le Bourget du Lac, Cedex
www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20141112/9582ce15/attachment.htm>


More information about the augeas-devel mailing list