]> git.saurik.com Git - bison.git/blobdiff - data/lalr1.cc
Merge remote-tracking branch 'origin/maint'
[bison.git] / data / lalr1.cc
index b3e46e953049579b8f6aaa4ed23ee63786370c37..3168758959a7fac05937a1bc1907683cb7e4f678 100644 (file)
@@ -22,7 +22,7 @@ m4_include(b4_pkgdatadir/[c++.m4])
 # --------------------------------------------------------------
 # Declare "parser::yy<TABLE-NAME>_" which contents is CONTENT.
 m4_define([b4_integral_parser_table_declare],
 # --------------------------------------------------------------
 # Declare "parser::yy<TABLE-NAME>_" which contents is CONTENT.
 m4_define([b4_integral_parser_table_declare],
-[m4_ifval([$3], [b4_c_comment([$3], [  ])
+[m4_ifval([$3], [b4_comment([$3], [  ])
 ])dnl
   static const b4_int_type_for([$2]) yy$1_[[]];dnl
 ])
 ])dnl
   static const b4_int_type_for([$2]) yy$1_[[]];dnl
 ])
@@ -120,7 +120,7 @@ m4_pushdef([b4_copyright_years],
 m4_define([b4_parser_class_name],
           [b4_percent_define_get([[parser_class_name]])])
 
 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])])])
   [# 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"
 # 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[
                                           [[# include "location.hh"]])])])[
 
 ]b4_YYDEBUG_define[
@@ -148,7 +148,7 @@ m4_define([b4_shared_declarations],
 
 ]b4_defines_if([],
 [b4_stack_define
 
 ]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])])])[
 
                                          [b4_position_define
 b4_location_define])])])[
 
@@ -683,6 +683,10 @@ m4_if(b4_prefix, [yy], [],
     /// The return value of parse ().
     int yyresult;
 
     /// 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], [
     YYCDEBUG << "Starting parse" << std::endl;
 
 ]m4_ifdef([b4_initial_action], [
@@ -721,20 +725,20 @@ b4_dollar_popdef])[]dnl
       {
         YYCDEBUG << "Reading a token: ";
         try
       {
         YYCDEBUG << "Reading a token: ";
         try
-        {
+          {
 ]b4_lex_symbol_if(
 ]b4_lex_symbol_if(
-[          yyla = b4_c_function_call([yylex], [symbol_type],
+[            yyla = b4_function_call([yylex], [symbol_type],
                                      m4_ifdef([b4_lex_param], b4_lex_param));],
                                      m4_ifdef([b4_lex_param], b4_lex_param));],
-[          yyla.type = yytranslate_ (b4_c_function_call([yylex], [int],
+[            yyla.type = yytranslate_ (b4_function_call([yylex], [int],
                                      [b4_api_PREFIX[STYPE*], [&yyla.value]][]dnl
 b4_locations_if([, [[location*], [&yyla.location]]])dnl
 m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
                                      [b4_api_PREFIX[STYPE*], [&yyla.value]][]dnl
 b4_locations_if([, [[location*], [&yyla.location]]])dnl
 m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
-        }
+          }
         catch (const syntax_error& yyexc)
         catch (const syntax_error& yyexc)
-        {
-          error (yyexc);
-          goto yyerrlab1;
-        }
+          {
+            error (yyexc);
+            goto yyerrlab1;
+          }
         yyempty = false;
       }
     YY_SYMBOL_PRINT ("Next token is", yyla);
         yyempty = false;
       }
     YY_SYMBOL_PRINT ("Next token is", yyla);
@@ -807,19 +811,19 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
     // Perform the reduction.
     YY_REDUCE_PRINT (yyn);
     try
     // Perform the reduction.
     YY_REDUCE_PRINT (yyn);
     try
-    {
-      switch (yyn)
       {
       {
+        switch (yyn)
+          {
 ]b4_user_actions[
 ]b4_user_actions[
-        default:
-          break;
+          default:
+            break;
+          }
       }
       }
-    }
     catch (const syntax_error& yyexc)
     catch (const syntax_error& yyexc)
-    {
-      error (yyexc);
-      YYERROR;
-    }
+      {
+        error (yyexc);
+        YYERROR;
+      }
     YY_SYMBOL_PRINT ("-> $$ =", yylhs);
 ]b4_variant_if([[
     // Destroy the rhs symbols.
     YY_SYMBOL_PRINT ("-> $$ =", yylhs);
 ]b4_variant_if([[
     // Destroy the rhs symbols.
@@ -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);
     /* 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_ ();
       {
         yy_destroy_ ("Cleanup: popping", yystack_[0]);
         yypop_ ();
@@ -963,6 +967,23 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
 
     return yyresult;
   }
 
     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)
 
   void
   ]b4_parser_class_name[::error (const syntax_error& yyexc)