Re: yacc question

rkrayhawk@aol.com (RKRayhawk)
3 May 1999 14:48:59 -0400

          From comp.compilers

Related articles
yacc question levap@rcn.com (Pavel Grinfeld) (1999-04-29)
Re: yacc question miano@colosseumbuilders.com (1999-04-30)
Re: yacc question rkrayhawk@aol.com (1999-05-03)
| List of all articles for this month |
From: rkrayhawk@aol.com (RKRayhawk)
Newsgroups: comp.compilers
Date: 3 May 1999 14:48:59 -0400
Organization: AOL http://www.aol.com
References: 99-04-103
Keywords: yacc, C++

Pavel, levap@rcn.com
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
of scope".
>>


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
destructors.


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
syntax).


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.


Best Wishes,


Robert Rayhawk
RKRayhawk@aol.com
[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]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.