help-bison
[Top][All Lists]
Advanced

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

Re: Token types with constructor


From: Laurence Finston
Subject: Re: Token types with constructor
Date: Thu, 26 Aug 2004 23:44:38 +0200
User-agent: IMHO/0.98.3+G (Webmail for Roxen)

Hans Aberg wrote:

> 
> Yes, your approach essentially avoids using C++ constructors. One
> shortcoming with this approach is that one cannot use C++ automatics to
> deallocate free store objects. So if one uses such objects pointed at by
> void*, one has to deallocate them by hand in the rule actions, plus using
> the experimental %destructor option to deallocate them during error
> recovery, that is, if it is essential for your program to avoid memory
> leaks.

I don't use `%destructor'.  I haven't checked whether it's in the version I'm
using (1.875, I believe).  My manual is a bit out-of-date.  I haven't started
working on recovery from parse errors, but I may do deallocation  there by
hand, anyway, assuming this is possible.  

I use `new' and `delete' explicitly in the actions, so I am using constructors
and destructors, it's just under my control rather than under that of
`yyparse()'.  I like to program this way.  Others who don't should probably
use your patch.

> 
> Even though my parser is not thread safe, it should be easy to make it so,
> by merely moving the parser stack into the function. Also, perhaps change
> std::vector to std::deque.

I'm not criticizing your approach, but I'm happy with mine.
I believe that my approach has advantages, too, but what really clinches the
matter for me is that I must use a stable release.   
If your changes are merged into a stable release, then one could decide which
approach was most suitable to the given task.
Until then, people who need to use stable releases won't be able to use your
approach.

Laurence



reply via email to

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