help-bison
[Top][All Lists]
Advanced

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

Re: Run-time selection of bison rule reduction?


From: Casey Leedom
Subject: Re: Run-time selection of bison rule reduction?
Date: Tue, 30 Apr 2002 08:53:32 -0700

| Date:  30 Apr 2002 17:23:51 +0200
| From:  Akim Demaille <address@hidden>
| 
| Casey> We could obviously #ifdef parse.y and dual compile flex but
| Casey> this would be somewhat awkward.  
| 
| That's what I recommend: you have two grammars, you need two parsers.  Bison
| has no better solution to offer, and I'm afraid it won't.

  I was able to handle this via a single grammer that accepts both
precedences, differentiated by having the lexical scanner return different
tokens for the repeat operator braces, {}, depending on whether we are in
AT&T or POSIX lex compatibility mode.  E.g.:

    "{"/[[:digit:]]     return '{';

becomes:

    "{"/[[:digit:]]     {
                              if (lex_compat || posix_compat)
                                  return BEGIN_REPEAT;
                              else
                                  return BEGIN_REPEAT_FLEX;

I had to duplicate the yacc/bison rules for the repeat operator but that was
only about 30 lines.  There might have been a way to avoid this repetition
but the size of the change and its uniqueness didn't justify that
investment.  Thanks for all the help everyone provided in understanding this
problem, offering commentary and suggestions.

Casey



reply via email to

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