[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 11:45:49 +0200 |
At 10:43 +0200 2002/10/14, Akim Demaille wrote:
>| Bison 1.50 does not seem to handle the pre & post prologues properly; that
>| is, when writing:
>| %{
>| pre_prologue
>| %}
>| ...
>| %{
>| post_prologue
>| %}
>| ...
>| %%
>| ...
>| in the .y files as above, the b4_post_prologue macro expands to empty, and
>| all stuff goes into the first b4_pre_prologue macro.
>|
>| -- I need this for writing my C++ skeleton file: Some stuff should then go
>| into the header and other into the source file. This is often required with
>| polymorphic classes and stuff relying on forward declarations, but also
>| useful in order to decrease the number of headers that the header includes.
>
>pre and post-prologue are implementation details. You should tell us
>what the *real* problem is.
>
>pre- and post-, as implementation details, are separated by %union.
I thought I did: If I write the code above, then:
>the b4_post_prologue macro expands to empty, and
>>| all stuff goes into the first b4_pre_prologue macro.
This makes it impoosible to write the correct C++ skeleton file, as some
prologue stuff may be put in the header, but certainly not all as in the
current lalr1.cc.
If I, in lalr1.cc, write:
...
#output "b4_output_prefix[]b4_output_infix[].cc"
b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
[2002])
#include "b4_output_header_name"
/* Copy the second part of user declarations to the C++ source file: */
b4_post_prologue
...
Then the post_prologue stuff above is not written to the C++ source file.
It does not have anything to do with %union, as %union cannot be used under
C++ if one wants to make of a very major C++ feature, classes with
nontrivial constructors.
Hans Aberg
* Email: Hans Aberg <mailto:address@hidden>
* Home Page: <http://www.matematik.su.se/~haberg/>
* AMS member listing: <http://www.ams.org/cml/>