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.




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



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

Reply via email to