CVS Bison, i.e., the development version of Bison, provides means to
release symbols during error recovery in the C++ parsers. But much
work remains to be done. You may either try it, or even improve Bison
itself. Contact Akim.
A more Elaborate Visitor Hierarchy
Voir spot, for an example on how the use of a clean visitor hierarchy
and auxiliary functions enhances the readability, maintainability, and
expressiveness of the code.
Using Generic Visitors
Andrei Alexandrescu has done a very interesting work on generic
implementation of Visitors, see Modern C++ Design. It does
require advanced C++ skills, since it is based on type lists, which
requires heavy use of templates.
Using Visitor Combinators
Going even further that Andrei Alexandrescu, Nicolas Tisserand proposes
an implementation of Visitor combinators, see Generic Visitors in C++.