help-bison
[Top][All Lists]
Advanced

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

Re: Problems with multithreading and slow compilation


From: Hans Aberg
Subject: Re: Problems with multithreading and slow compilation
Date: Thu, 8 Jul 2004 01:12:19 +0200

At 21:01 +0200 2004/07/07, Laurence Finston wrote:
>On Wed, 7 Jul 2004, Hans Aberg wrote:
>
>> At 19:22 +0200 2004/07/07, Laurence Finston wrote:
>> >> What C++ file are you speaking about: The C one compiled as C++, the one
>> >> that comes with the distribution, the one I wrote, or someone else.
>> >
>> >The one generated by running Bison on the Bison input file.  Of
>> >course, it's only a C++ file by virtue of the C++ code in the actions.
>>
>> This is the C one compiled as C++. (As discussed before) it will break if
>> you use C++ classes with nontrivial constructors in the parser semantic
>> value, as the C parser stack does not know how to invoke those when
>> reallocating.
>>
>
>I don't.  It's not possible because I use `%union' and "... a union
>may not have members with constructors or destructors."

If you have a compliant compiler, that is: Once upon time, it was common
for C++ compilers to no check this.

>(Stroustrup, _The C++ Programming Language_, p. 257).

It is in the C++ standard, sec 9.5:1 [class.union].

>  I use `void*' instead
>and cast pointers to objects back and forth as needed.

I use C++ polymorphic (virtual) hierarchy. At one point n time, I
experimented with a Bison extension %type which put on the Bison static
typing feature without implementing a union for the semantic value type.

But it turned out that I did not need the %type feature, as one fan check
errors in the C++ code at runtime: One uses dynamic_cast on either
pointers, which are checked if the result in 0, or on references, in which
case an exception is thrown in the case of type errors.

So it is not really needed: In most cases, one knows what to write, and the
few cases where an error is made, it is detected when running the C++ code.

  Hans Aberg






reply via email to

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