help-bison
[Top][All Lists]
Advanced

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

Re: Deallocations upon parse errors?


From: David Fang
Subject: Re: Deallocations upon parse errors?
Date: Tue, 16 Jan 2007 23:10:05 -0500 (EST)

> Pick down some later version of Bison (2.3+); then, if you use the C
> parser, there is a %destructor command, that can be used to handle
> clean-up during error recovery. Another way is to use a C++ parser,
> and a semantic type that does cleanup via the C++ language, but one
> cannot then use %union.
>
>    Hans Aberg

Hi,
        One of these days I'll sit down an use the new %destructor feature
in bison, but FWIW, it IS *possible* to to clean-up of the parser stack in
C++, using only the C skeleton, and while using a union of various pointer
types.  It involves deducing the union type based on the state numbers and
transitions on the parser stack.  I described the recipe for doing this in
an old thread.

http://lists.gnu.org/archive/html/help-bison/2006-04/msg00023.html

Yeah, it might be disgusting, but it was educational.  :)

I verified that no symbol objects were leaked in the event of parse errors
by defining class-overloaded operator new/delete (for all pointee types in
the union) to use pool-allocators and asserting that the pools were
'clean' upon global static destruction.  This method works with
traditional yacc, byacc, and all released versions of bison from 1.35 to
2.3 (present).

Fang





reply via email to

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