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: Hans Aberg
Subject: Re: Conditional generation of Grammar rules
Date: Tue, 2 May 2006 19:49:36 +0200

One way of handling this is to merge the two grammars, and making them selectable by a special token, which is then used at runtime. The .y grammar is entirely static, and is even thrown away by the LALR (1) algorithm that Bison uses, so the generated parser does not know anything about it, and in particular, cannot be accessed at all at parser runtime.

On 2 May 2006, at 18:37, Jeganatan, Srividhya wrote:

All,
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.

Thanks for your help.

Srividhya.




_______________________________________________
address@hidden http://lists.gnu.org/mailman/listinfo/help-bison





reply via email to

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