help-bison
[Top][All Lists]
Advanced

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

Re: Memory Leaks


From: Hans Aberg
Subject: Re: Memory Leaks
Date: Sat, 18 Nov 2006 21:27:31 +0100

On 18 Nov 2006, at 17:39, Paulo J. Matos wrote:

There is now %destructor to clean up C-code leaks during error
recovery; otherwise, do it by hand in the actions.

What do you mean by error recovery? If the parsing fails?

Right.

I still cannot understand when %destructor code is called.

The parser stack is unwound, skipping rule actions, until a recovery is deemed possible. So then special cleanup code must be written by hand.

I think the
developers have worked hard to plug the Bison generated parsers. I
don't use C, but C++, in which case one can use language features to
do the cleanup.

I also use C++ (generating C++ lexer and C parser, I find the C++
bison interface incomprehensible). What do you mean by language
features to clean it up?

The C++ parser uses for parser stack a class like std::vector or std::deque, which invokes the class destructors when the stack is unwound. So if the classes of the objects on the parser stack are properly written, no special cleanup is needed.

  Hans Aberg






reply via email to

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