bug-bison
[Top][All Lists]
Advanced

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

Re: beta testing


From: Hans Aberg
Subject: Re: beta testing
Date: Wed, 21 Feb 2001 12:58:13 +0100

At 12:05 +0100 2001/02/21, Philippe Bekaert wrote:
>> Another way around this problem is to write another header foo_bar.tabb.h
>> whose contents is
>>    #ifndef foo_bar_header
>>    #define foo_bar_header
>>    #include "foo_bar.tab.h"
>>    #endif /* foo_bar_header */
>>
>> Then, instead of foo_bar.tab.h, include the header foo_bar.tabb.h into your
>> program.
>That doesn't work: you need the _same_ declaration of YYSTYPE in the
>class declaration _and_ in the implementation.
>
>Regardless of the context in which I encounter this problem, the general
>problem is:
>
>"If you include y.tab.h in the bison script (for whatever reason), you
>get duplicate declarations on YYSTYPE".

I don't really understand what you are doing: With my suggestion, no file
should include the .tab.h file, only the .tabb.h file does that; instead
include the .tabb.h file. Then the declaration the macros in the .tab.h
file will be read singly from any file that includes .tabb.h file, no
matter thow many times the latter is included.

The .tab file contains
  #ifndef YYSTYPE
  # define YYSTYPE int
  #endif
which means that you must include the header where you define YYSTYPE
before you include the .tabb.h file, otherwise it will substitute a default
definition.

>Why not solve the problem as follows:
>
>"If bison is invoked with the -d flag (requesting y.tab.h to be
>generated), then #include "y.tab.h" in the generated y.tab.c file
>instead of duplicating the declarations and generate y.tab.h wrapped in
>proper conditionals avoiding duplicate inclusion."

This statement is so complicated that I cannot follow what you are saying:

There is no point in including the .tab.h from the .tab.c file, as it is
not needed -- it's there only so that the lexer can read those macros. Even
though one can think of including it from the .tab.c file, and excluding
the macro defined in it on the same time.

The contents of .tab.h file ought to be properly wrapped by conditional
macros, yes. In addition, I think that some of the things needed from the
lexer should be written into header, as well.

  Hans Aberg





reply via email to

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