help-bison
[Top][All Lists]
Advanced

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

Re: Problems using bison and flex with C++


From: Hans Aberg
Subject: Re: Problems using bison and flex with C++
Date: Thu, 24 Jun 2004 19:55:13 +0200

At 09:29 +0200 2004/06/23, Laurence Finston wrote:
>On Tue, 22 Jun 2004, Hans Aberg wrote:
>> The Bison C parser will not work under C++ for several reasons, for
>> example, its stack does not invoke copy constructors when re-allocating. As
>> I could not get the Bison C++ parser working directly, I wrote my own. The
>> details are posted in the Bison-Patches group. Some fellows said that they
>> were able to follow the instructions to get a working C++ parser on their
>> own. I think this is the state of the matter, until somebody writes a
>> (working) C++ parser that comes with the Bison distribution.
...
>I don't understand this. I'm using Bison with C++ and I haven't had any
>problems. With very few exceptions valid C code should also be valid
>C++ code.  Am I missing something here?

You probably want me to repeat what I just wrote above:

>> The Bison C parser will not work under C++ for several reasons, for
>> example, its stack does not invoke copy constructors when re-allocating.

So if your C++ parser class use non-trivial copy-constructors, and the C
stacks are re-allocated, the new stuff on the new stack will be wrong. You
will be safe if you do not feed an input segment that is so big that the
C-stacks re-allocate, or if you only use POD on your parser stack (which
must be the case if you use say the %union feature together with a
compliant C++ compiler, as non-POD's will then be rejected).

  Hans Aberg






reply via email to

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