[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bison 1.50 pre & post prologue bug
From: |
Hans Aberg |
Subject: |
Re: Bison 1.50 pre & post prologue bug |
Date: |
Mon, 14 Oct 2002 16:14:59 +0200 |
I was able to tweak the Biosn 1.50 sources to:
/*----------------------------------------------------------------.
| There are two prologues: one before %union, one after. Augment |
| the current one. |
`----------------------------------------------------------------*/
int prologue_count = 0;
void
prologue_augment (const char *prologue, location_t location)
{
struct obstack *oout =
(!typed && !prologue_count++) ? &pre_prologue_obstack :
&post_prologue_obstack;
...
This way, the second prologue will end up into the post_prologue_obstack
regardless whther %union has been defined.
-- I think that the prologues should not be tied to the definition of
%union, because that will break under C++.
Therefore, I think that the code above should be:
int prologue_count = 0;
void
prologue_augment (const char *prologue, location_t location)
{
struct obstack *oout =
(!prologue_count++) ? &pre_prologue_obstack : &post_prologue_obstack;
...
Possibly, if there is more than two prologues there should be an error.
Then, %union will appear in the output as in the input relative the two
possible prologues.
One problem with the tweak is that under C++, if one wants no stuff in the
header, one must declare an empty pre-prologue. But that is OK for now, I
think.
Hans Aberg