[augeas-devel] brics grammar

David Lutterkort lutter at redhat.com
Fri Aug 27 20:32:39 UTC 2010


On Mon, 2010-08-23 at 22:03 -0400, Francis Giraldeau wrote:
> I'm working on getting brics grammar with recursive lens. It was not
> hard at all in fact, and it's almost the same function as print_grammar,
> but slightly changed for brics syntax. 

Excellent.

> I do have two problems. The first is that regexp have few differences on
> how they are escaped. For example, the single char "-" must be escaped,
> and it's not the case with print_regexp. I don't know the impact of
> changing the escaped_chars...

Do you mean escaped_chars in fa.c ? (There's also an escape in
internal.c, but that's concerned with transforming a string from/to the
equivalent C-like string format)

libfa uses extended POSIX regexp syntax. According to regex(7),
unnecessarily escaping characters outside of character classes should be
fine (since "-" and "\\-" both match only "-")

It might be a little confusing in error messages since users will
enter /a-b/ and error messages will tell them that something's wrong
with /a\-b/

You should be able to do the "-" escaping fairly easily in the print
routines by scanning the string and printing it character by character.
The only hairy bit is that you need to track whether you are inside a
character set or not, and that a ']' immediately after '[' or '[^' does
_not_ end the character set.

> The other problem is more related to brics... It's like if it was using
> the identifier label as a static string in the grammar, instead of using
> the corresponding regexp. Weird. Will dig into it later this week.
> 
> Anyway, here it is: 
> 
> http://github.com/giraldeau/augeas/tree/brics
> 
> mkdir -p /tmp/augeas
> export AUGEAS_DEBUG_DIR=/tmp/augeas
> export AUGEAS_DEBUG=cf.brics.file
> or
> export AUGEAS_DEBUG=cf.brics.stdout

Nice stuff ... I think the ability to hook brics' grammar ambiguity
checker in will be a great help for hairier cases of cf grammars.

David





More information about the augeas-devel mailing list