|yacc question email@example.com (Pavel Grinfeld) (1999-04-29)|
|Re: yacc question firstname.lastname@example.org (1999-04-30)|
|Re: yacc question email@example.com (1999-05-03)|
|Date:||3 May 1999 14:48:59 -0400|
Date: 29 Apr 1999 00:47:33 -0400
posted a description of ".. a major yacc predicament. ... using C++. ... (and)
... a custom type YYSTYPE which is a class ...".
Particularly, it is desired to
<< rely on instances of this class calling their distructors when they "go out
This may not be a yacc problem per se. Generally, if you declare any
constructor at all, most C++ compiler "automatic" features become
disengaged. When you take things into your own hands the compiler
will not deploy its own (language default) constructors or
This creates a number of problems, including the fact that you may not
be specifically creating a destructor that the technology will pick up
as the appropriate automatic correlary to the constructor that you
successfully engaged (even if the constructor is engaged with implicit
So if you have specified constructors for YYSTYPE you must specify any
destructor needed, which must be competent to genuinely scrub the
system of all members of the structure, and the structure itself.
There is nothing about yacc that damages the scoping facilities of a
C++ compiler. So you should be able to get what you want, it is just
that in C++, if you take the constructor-destructor coding task
bravely into your own hands, then you must take it all.
If you have the time, post some code so that we can see how you are
actually passing the address of supposedly newly instantiated YYSTYPE
objects, and briefly explain the symptom that convinces you yacc is
seeing an old instance.
Feel free to e-mail larger code snippets if you want. Yacc will live in C++,
don't be discouraged.
[The main problem is that YYSTYPE is normally a union, and C++ can't
tell what type is stored in the union and hence can't call destructors
properly. If you declare it yourself either as a structure or as a
union and a type word. with your own code to do constructors, destructors,
assignments, etc., it should work. -John]
Return to the
Search the comp.compilers archives again.