Why don't you just rewrite the same this way ... it seems much simpler to
me.
nonterminal X:
{
#ifdef FEATURE
rule1;
#else
rule1; rule2;
#endif
}
would it be a problem for you to write it this way?? Or is your problem much
bigger than what I just addressed.
Regards
Ramaswamy
-Original M
> 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?
Sure, (at the risk of being slightly off-topic)...
> > nonterminal X:
> > #ifdef FEATURE
> > { rule 1 }
> > #else
> > { rule 1; rule 2 }
> > #endif
Place
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,
idhya
Cc: 'help-bison@gnu.org'
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
> 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 pos