> 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 _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison