]> git.saurik.com Git - bison.git/blobdiff - data/lalr1.cc
Merge remote-tracking branch 'origin/maint'
[bison.git] / data / lalr1.cc
index 75eaf571e6c82afaa021c4245ac3b7fdcfa3d0e5..3168758959a7fac05937a1bc1907683cb7e4f678 100644 (file)
@@ -120,7 +120,7 @@ m4_pushdef([b4_copyright_years],
 m4_define([b4_parser_class_name],
           [b4_percent_define_get([[parser_class_name]])])
 
-b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
+b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
   [# Backward compatibility.
    m4_define([b4_location_constructors])
    m4_include(b4_pkgdatadir/[location.cc])])])
@@ -139,7 +139,7 @@ m4_define([b4_shared_declarations],
 # include <stdexcept>
 # include <string>]b4_defines_if([[
 # include "stack.hh"
-]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
+]b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
                                           [[# include "location.hh"]])])])[
 
 ]b4_YYDEBUG_define[
@@ -148,7 +148,7 @@ m4_define([b4_shared_declarations],
 
 ]b4_defines_if([],
 [b4_stack_define
-b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
+b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],
                                          [b4_position_define
 b4_location_define])])])[
 
@@ -683,6 +683,10 @@ m4_if(b4_prefix, [yy], [],
     /// The return value of parse ().
     int yyresult;
 
+    // FIXME: This shoud be completely indented.  It is not yet to
+    // avoid gratuitous conflicts when merging into the master branch.
+    try
+      {
     YYCDEBUG << "Starting parse" << std::endl;
 
 ]m4_ifdef([b4_initial_action], [
@@ -955,7 +959,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
     /* Do not reclaim the symbols of the rule which action triggered
        this YYABORT or YYACCEPT.  */
     yypop_ (yylen);
-    while (yystack_.size () != 1)
+    while (1 < yystack_.size ())
       {
         yy_destroy_ ("Cleanup: popping", yystack_[0]);
         yypop_ ();
@@ -963,6 +967,23 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
 
     return yyresult;
   }
+    catch (...)
+      {
+        YYCDEBUG << "Exception caught: cleaning lookahead and stack"
+                 << std::endl;
+        // Do not try to display the values of the reclaimed symbols,
+        // as their printer might throw an exception.
+        if (!yyempty)
+          yy_destroy_ (YY_NULL, yyla);
+
+        while (1 < yystack_.size ())
+          {
+            yy_destroy_ (YY_NULL, yystack_[0]);
+            yypop_ ();
+          }
+        throw;
+      }
+  }
 
   void
   ]b4_parser_class_name[::error (const syntax_error& yyexc)