[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Factor %FLAG at scan level.

From: Akim Demaille
Subject: Re: [PATCH] Factor %FLAG at scan level.
Date: Fri, 3 Apr 2009 10:54:06 +0200

Le 3 avr. 09 à 06:50, Akim Demaille a écrit :

        * src/parse-gram.y (PERCENT_DEBUG, PERCENT_ERROR_VERBOSE): Token
        definitions and associated rules, replaced by....
        (PERCENT_FLAG): this new token type, and rule.
        * src/scan-gram.l (RETURN_PERCENT_FLAG): New.
        Use it for %debug and %error-verbose.

Sorry about this one, I meant to push it (actually there are three like this one, plus three "regen") onto our local git repository, I am not yet sure it is a good idea. So now that it's pushed (I attach the two missing patches below, they go before this one), maybe that's an opportunity to discuss about it. I'm fine with reverting, of course.

These patches correspond to something that I had in mind for a long time, but did not feel compelled to try so soon.

We have several ways to manage flags (and actually even non-Boolean variables): via options (e.g., --debug), via directives (e.g., %debug), and we now have Boolean variables (e.g., %define assert). One interface should suffice, and of course that's the %define based one. We have all the infrastructure for it (courtesy of Joel) with nice and precise error/warning messages). We have a yes and no interface in the grammar file (%define assert "true" vs. %define assert "false") which is not the case for %options such as %debug, and similarly for options via -Dassert=true/-Dassert=false. As a result, options that are enabled by default, have a "no-"name: --no-lines/%no- lines.

So I think we should phase out %debug and the like, and make them be sugar for "%define debug", a bit like Flex did with %option. It should make a smaller code base, and more possibilities.

Why did I try now? But on our project our executable is too large, and we're looking for ways to save bytes. It occurred to me that getting rid of %error-verbose is a way to get a few KB from Bison. In the Makefiles is was much simpler to have


and AC_SUBST([YYERROR_VERBOSE], [false]) or true rather than having to *subtract* the --error-verbose flag from the default set of AM_BISONFLAGS. I hope I'm clear here, if I'm not, bottom line is: it makes Makefiles simpler.

If the idea is accepted, there are a few issues:

- factoring comes with a price: the error messages will go from "unexpected %debug" to "unexpected %<flag>". Big deal?

- should -Derror-verbose and -Derror_verbose be the same?

- locations_flag is a bit more of a problem, as it can be activated implicitly when we encounter a @$ or so. I would like to deprecate (but I guess never remove) the implicit use of locations not declared via %locations (well, %define locations)).

- we should probably also have priority management so that the grammar file can declare %define debug, but be overriden by -Ddebug=false.

- we should probably also do that for variables that take an argument, such --defines=FILE.

- but where is the limit? What options will remain true options rather that wrappers around muscle-variables?

Attachment: 0004-Treat-error-verbose-as-define-error_verbose.patch
Description: Binary data

Attachment: 0006-Treat-debug-as-define-debug.patch
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]