[Top][All Lists]

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

Re: [PATCH] More %define/%code encapsulation

From: Joel E. Denny
Subject: Re: [PATCH] More %define/%code encapsulation
Date: Wed, 17 Jan 2007 01:01:43 -0500 (EST)

On Tue, 16 Jan 2007, Paolo Bonzini wrote:

> This patch defines the conditional macros for %define and %code.

Just out of curiosity, are you actually using all these new macros, or are 
you just anticipating that someone might find them useful?

I ended up not adding the _ifdef's in my previous patch because I wasn't 
sure what I'd ever use them for.  Thinking about it now, I guess some 
skeletons might want to require certain %define's or %code's and 
warn/complain when the grammar doesn't define them.  Is that what you're 
thinking?  Anything else?

b4_percent_define_if encapsulates the concept of a %define boolean, so I 
can see it as a way to help keep boolean handling consistent.

b4_percent_define_case and b4_percent_define_ifval seem to do very little 
beyond the code they wrap.  They don't even abbreviate it much.  Do we 
really need them?  By the way, I'm not sure the m4_quote's there have any 
effect since the Bison front-end guarantees that the values are quoted.

> In addition,
> it changes b4_percent_code_unqualified to simply b4_percent_code() since the
> special casing is not necessary.

That's better.

> I tested the macros manually, with a modified yacc.c.  If you want I can try
> adding testcases with a specially written skeleton that exercises the new
> macros.

That's a good idea.  How about a tests/  I assume you'll have 
test cases generate test skeletons just like test grammars.  I'll 
implement relative and absolute skeleton file names soon to make this 

> +# b4_percent_define_ifdef(VARIABLE, IF-TRUE, IF-FALSE)
> +# ----------------------------------------------------
> +# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand
> +# IF-EMPTY.  Also, record the skeleton's usage of VARIABLE by defining


> +# b4_percent_define_if(VARIABLE, IF-TRUE, IF-FALSE)
> +# -------------------------------------------------
> +# If the %define variable VARIABLE is defined to anything but 0, evaluate 
> +# If it is defined to 0, evaluate IF-FALSE.

In my experience, an empty string also means false.

> +# b4_percent_define_case(VARIABLE, [VALUE1, THEN1]..., ELSE)
> +# ----------------------------------------------------------
> +# If the %define variable VARIABLE is defined to VALUE1, evaluate THEN1, and
> +# so on.  If none of the values match, expaand ELSE.

Isn't the ELSE argument optional?  In the other macros, isn't IF-FALSE 

reply via email to

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