On Thu, 4 Feb 2010, fi...@code2develop.com wrote: > I have a bison grammar file, and I would like to enable/disable certain > rules based on a variable. > > So for example: > > rule1 : rule2 | rule3 | rule4 > rule2: A B C > rule3: D E F rule2 > rule4: rule2 | G > > On a certain day I only want rule 4 disabled. Is there a possibility to > do such a thing in bison?
Not in general. The parser actions are hard-coded into the parser tables by Bison. If there are alternative ways to parse the same input, you can use %glr-parser with %merge to provide code that decides how to merge the semantic values resulting from multiple rules. It could select one of the rule's values based on some variable. The rules whose values it doesn't select are thus, in some sense, disabled. Be forewarned that GLR is tricky. See the Bison manual for details. _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison