help-bison
[Top][All Lists]
Advanced

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

RE: Conditional generation of Grammar rules


From: Jeganatan, Srividhya
Subject: RE: Conditional generation of Grammar rules
Date: Tue, 2 May 2006 12:58:08 -0400

Fang,
Thanks for the response.
But I'm not sure I understood what you have mentioned.
Could you please give an example or a bit more detail?

Appreciate it.

Thanks!

-----Original Message-----
From: David Fang [mailto:address@hidden
Sent: Tuesday, May 02, 2006 12:55 PM
To: Jeganatan, Srividhya
Cc: 'address@hidden'
Subject: Re: Conditional generation of Grammar rules


> Is there a way to conditionally generate grammar rules?
> For example, I need to do something like
>
> nonterminal X:
> #ifdef FEATURE
>  { rule 1 }
> #else
>  { rule 1; rule 2 }
> #endif
>
> I know that ifdefs dont work with the grammar but is there anything
> else that can be done? Or is it possible to make bison to read define
> variables from a make file?
>
> I want to avoid writing different parsers / recursive parsers to do this.

Hi,
        You could generate your .y file explicitly using cpp, going from
.y.in -> .y, and using a separaete header to define your feature sets.
(I do something similar with autoconf-configure, for example.)  Or you
could generate it with a more sophisticated preprocessor like m4.

Fang




reply via email to

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