[augeas-devel] Unable to resolve the ambiguity of a lens
Lukas Krejci
lkrejci at redhat.com
Mon Dec 7 00:16:21 UTC 2009
Hi,
using the lastest Augeas 0.6.0, I'm trying to develop a lens that would read
following format:
Command := command_name [separator parameter]*
where each command would be on a single line and placing a '\' as a last
character on the line would "escape" that newline and allow the command to
continue on the next line.
For that I wrote the following lens:
module Test =
let sep = del /([ \t]+(\\\\\n)?)+/ " "
let eol = del /[ \t]*\n/ "\n"
let word = /[^ \t\n]+/
let alnum = /[a-zA-Z0-9_]+/
let command = [ del /[ \t]*/ "" . key alnum . [ sep . label "param" . store
word ]* . eol ]
let lns = command*
When I run "augparse -I . --nostdinc test.aug", the command rule is ambiguous
with the following message:
Syntax error in lens definition
test.aug:10.0-.18:Failed to compile lns
test.aug:10.10-.18:exception: ambiguous iteration
Iterated regexp: /([ \t]*)([a-zA-Z0-9_]+)(((([ \t]+(\\\\\n)?)+)([^
\t\n]+))*)([ \t]*\n)/
'A \\\nA\n' can be split into
'A \\\n|=|A\n'
and
'A \\\nA\n|=|'
Iterated lens: test.aug:8.14-.91:
which I understand as that the parser cannot decide whether the second "A"
forms a new command or a new parameter of a previous command (alnum and word
regexes overlap).
Could you explain why is the parser not able to do that? It seems to me clear
that the latter example should always be used because a command must always be
ended by a newline, which it isn't in the first example in the error message.
Is there a way of reformulating the rules such that the escaped new lines in
this generic scenario are possible or have I found a bug?
Thanks,
Lukas
More information about the augeas-devel
mailing list