From d3e4409ad1da0fe2625a6f77e9a5b93a0a6e6647 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 1 Oct 2012 11:41:26 +0200 Subject: [PATCH 1/1] lalr1.cc: document exception safety * NEWS: here. * doc/bison.texi (Destructor Decl, C++ Parser Interface): and there. --- NEWS | 9 +++++++++ doc/bison.texi | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/NEWS b/NEWS index c8a4d312..81afe649 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,15 @@ GNU Bison NEWS will use YY_CALC_LIB_PARSE_H_INCLUDED as guard. +** Exception safety (lalr1.cc) + + The parse function now catches exceptions, uses the %destructors to + release memory (the lookahead symbol and the symbols pushed on the stack) + before rethrowing the exception. + + This feature is somewhat experimental. User feedback would be + appreciated. + * Noteworthy changes in release 2.6.2 (2012-08-03) [stable] ** Bug fixes diff --git a/doc/bison.texi b/doc/bison.texi index ba18d9a9..ce1ebd11 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -4701,6 +4701,10 @@ incoming terminals during the second phase of error recovery, the current lookahead and the entire stack (except the current right-hand side symbols) when the parser returns immediately, and @item +the current lookahead and the entire stack (including the current right-hand +side symbols) when the C++ parser (@file{lalr1.cc}) catches an exception in +@code{parse}, +@item the start symbol, when the parser succeeds. @end itemize @@ -9415,6 +9419,11 @@ Build a new parser object. There are no arguments by default, unless @deftypemethod {parser} {int} parse () Run the syntactic analysis, and return 0 on success, 1 otherwise. + +@cindex exceptions +The whole function is wrapped in a @code{try}/@code{catch} block, so that +when an exception is thrown, the @code{%destructor}s are called to release +the lookahead symbol, and the symbols pushed on the stack. @end deftypemethod @deftypemethod {parser} {std::ostream&} debug_stream () -- 2.45.2