[augeas-devel] Recursive lens and "malformed node" error in put direction
Raphaël Pinson
raphink at gmail.com
Mon Feb 14 17:15:15 UTC 2011
Hi again,
I'm currently working on aptconf.aug, which is a recursive lens. I've
managed to make it parse what I wanted so far, but I get a "Malformed
node" error in the put direction.
The code is :
let name_re = /[A-Za-z][A-Za-z:-]*/
let rec entry =
let value =
Util.del_str "\"" . store Rx.word
. del /";[ \t]*\n?/ "\";\n" in
let list_elem =
[ label "@elem" . Util.indent . value ] in
[ indent
. key name_re
. (
(Sep.space . value)
| (del /[ \t\n]*\{[ \t]*/ " {"
. (entry|list_elem|empty|comment)+
. del /[ \t]*\}[ \t;]*\n?/ "};\n")
)
]
(* View: lns
The apt.conf lens *)
let lns = ( empty | comment | entry | include | clear )*
To get what it does, here are some tests that _pass_:
(* Test a simple entry *)
let simple_entry = "APT::Clean-Installed \"true\";\n"
test AptConf.entry get simple_entry =
{ "APT::Clean-Installed" = "true" }
(* Test simple recursivity *)
let simple_recursion = "APT { Clean-Installed \"true\"; };\n"
test AptConf.entry get simple_recursion =
{ "APT" { "Clean-Installed" = "true" } }
(* Test simple recursivity with several entries *)
let simple_recursion_multi =
"APT {
Clean-Installed \"true\";
Get::Assume-Yes \"true\";
}\n"
test AptConf.entry get simple_recursion_multi =
{ "APT"
{}
{ "Clean-Installed" = "true" }
{ "Get::Assume-Yes" = "true" } }
(* Test multiple recursivity *)
let multiple_recursion =
"APT { Get { Assume-Yes \"true\"; } };\n"
test AptConf.entry get multiple_recursion =
{ "APT" { "Get" { "Assume-Yes" = "true" } } }
(* Test simple list *)
let simple_list = "DPKG::options { \"--force-confold\"; }\n"
test AptConf.entry get simple_list =
{ "DPKG::options" { "@elem" = "--force-confold" } }
(* Test recursive list *)
let recursive_list =
"DPKG {
options {
\"--force-confold\";
\"--nocheck\";
} };\n"
test AptConf.entry get recursive_list =
{ "DPKG"
{}
{ "options"
{}
{ "@elem" = "--force-confold" }
{ "@elem" = "--nocheck" } } }
Now the problem...
I manage to do a put with the AptConf.entry lens:
(* Test put recursive value *)
test AptConf.entry put "APT { Clean-Installed \"true\"; }\n"
after set "/APT/Clean-Installed" "false" =
"APT { Clean-Installed \"false\"; }\n"
But a put with the AptConf.lns:
(* Test with full lens *)
test AptConf.lns put "APT { Clean-Installed \"true\"; }\n"
after set "/APT/Clean-Installed" "false" =
"APT { Clean-Installed \"false\"; }\n"
fails with:
tests/test_aptconf.aug:120.3-122.44:exception thrown in test
tests/test_aptconf.aug:120.8-121.46:exception: Malformed child node
Lens: ./aptconf.aug:105.10-.56:
Error encountered at path
Syntax error in lens definition
Failed to load tests/test_aptconf.aug
Am I doing something wrong?
I can post the full module code if necessary.
Raphaël
More information about the augeas-devel
mailing list