[augeas-devel] Fixing ambiguous iteration errors
Tom Limoncelli
tal at whatexit.org
Mon Oct 31 22:29:30 UTC 2011
Thanks for the help so far. I took your advice and looked at json.aug
for inspiration.
The format of the file looks like lisp:
# comment (always starts on column 0)
(foo bar)
(foo 'bar')
(foo (bar bar bar))
(foo (bar bar
bar))
# Blank lines also permitted
Currently I keep getting:
Syntax error in lens definition
./xendconfsxp.aug:31.0-.50:Failed to compile lns
./xendconfsxp.aug:31.12-.30:exception: overlapping lenses in tree union.put
Example matched by both:
First lens: ./xendconfsxp.aug:29.12-.55:
Second lens: ./xendconfsxp.aug:16.17-.36:
The example is blank. I'm not sure if that means "\n" or "" or if
this is a bug.
Here's the module:
1 module Xendconfsxp =
2 autoload xfm
3
4 let spc1 = /[ \t\n]+/
5 let ws = del spc1 " "
6
7 let lbrack = del /\([ \t\n]*/ "("
8 let rbrack = del /[ \t\n]*\)/ ")"
9
10 (*
11 First attempt which didn't work. Commenting this out and using
more simple one for now.
12 let no_ws_comment =
13 [ label "#comment" . del /#[ \t]*/ "# "
14 . store /[^ \t]+[^\n]*/ . del /\n/ "\n" ]
15 *)
16 let empty_line = del /[ \t]*\n/ "\n"
17 let no_ws_comment = del /#[^\n]*\n/ "#\n"
18
19 let var_name = key Rx.word
20 (* Either a word or a quoted string *)
21 let str_store = store /[A-Za-z0-9_.-]+|\"([^\"\\\\]|(\\\\.))*\"/
22 let str = [ label "string" . str_store ]
23
24 let rec thing =
25 let array = [ label "array" . lbrack . Build.list thing ws
. rbrack ] in
26 let str = [ label "item" . str_store ] in
27 str | array
28
29 let sexpr = lbrack . [ var_name . ws . thing ] . rbrack
30
31 let lns = ( sexpr | empty_line | no_ws_comment ) *
32
33 let filter = incl "xend-config.sxp" . Util.stdexcl
34 let xfm = transform lns filter
The actual files are here:
http://whatexit.org/tal/augeas/3/xendconfsxp.aug.txt
http://whatexit.org/tal/augeas/3/test_xendconfsxp.aug.txt
I can narrow the problem down to an even more simple case. At least I
think this is the same:
module Foo =
let ws = del /[ \t\n]+/ " "
let a = key /a+/
let b = [ label "b" . store /b+/ ]
let lns = ws | a | b
test lns get "aaa bbb " = ?
$ /usr/local/bin/augparse foo.aug
Syntax error in lens definition
foo.aug:5.2-.22:Failed to compile lns
foo.aug:5.12-.18:exception: overlapping lenses in tree union.put
Example matched by both:
First lens: foo.aug:2.11-.29:
Second lens: foo.aug:3.10-.18:
I'm unclear what I'm doing wrong. Suggestions?
Thanks in advance!
Tom
More information about the augeas-devel
mailing list