]> git.saurik.com Git - bison.git/blobdiff - data/lalr1.cc
portability: fix test suite for GCC 4.5's new #error message.
[bison.git] / data / lalr1.cc
index 36c8d581eba55622b5955af443473c84516d807d..b89a6df856214f634054942ff55ce3f95cc2442e 100644 (file)
@@ -1,7 +1,6 @@
 # C++ skeleton for Bison
 
-# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-# Free Software Foundation, Inc.
+# Copyright (C) 2002-2010 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +28,7 @@ m4_define([b4_integral_parser_table_declare],
 ])
 
 # b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
-# ---------------------------------------------
+# -------------------------------------------------------------
 # Define "parser::yy<TABLE-NAME>_" which contents is CONTENT.
 m4_define([b4_integral_parser_table_define],
 [  const b4_int_type_for([$2])
@@ -116,7 +115,7 @@ m4_popdef([b4_dollar_dollar])dnl
 
 
 m4_pushdef([b4_copyright_years],
-           [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])
+           [2002-2010])
 
 m4_define([b4_parser_class_name],
           [b4_percent_define_get([[parser_class_name]])])
@@ -147,6 +146,7 @@ dnl FIXME: This is wrong, we want computed header guards.
 ]b4_percent_code_get([[requires]])[
 
 ]b4_parse_assert_if([#include <cassert>])[
+#include <stdexcept>
 #include <string>
 #include <iostream>
 #include "stack.hh"
@@ -320,7 +320,7 @@ do {                                                            \
       /// The state.
       state_type state;
 
-      /// Return the type corresponding to this state.
+      /// The type (corresponding to \a state).
       inline int type_get_ () const;
     };
 
@@ -397,7 +397,7 @@ m4_if(b4_prefix, [yy], [],
 b4_percent_code_get[]dnl
 
 [#ifndef YY_
-# if YYENABLE_NLS
+# if defined YYENABLE_NLS && YYENABLE_NLS
 #  if ENABLE_NLS
 #   include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -668,7 +668,7 @@ b4_percent_code_get[]dnl
   inline bool
   ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue)
   {
-    return yyvalue == 0 || yyvalue == yytable_ninf_;
+    return yyvalue == yytable_ninf_;
   }
 
   int
@@ -814,12 +814,21 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
 
     // Perform the reduction.
     YY_REDUCE_PRINT (yyn);
-    switch (yyn)
+    try
+    {
+      switch (yyn)
       {
 ]b4_user_actions[
        default:
           break;
       }
+    }
+    catch (const syntax_error& yyexc)
+    {
+      error (]b4_args(b4_locations_if([yyexc.location]),
+                      [[yyexc.what()]])[);
+      YYERROR;
+    }
     YY_SYMBOL_PRINT ("-> $$ =", yylhs);
 ]b4_variant_if([[
     // Destroy the rhs symbols.
@@ -866,7 +875,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
         /* Return failure if at end of input.  */
         if (yyla.type == yyeof_)
           YYABORT;
-        else
+        else if (!yyempty)
           {
             yy_destroy_ ("Error: discarding", yyla);
             yyempty = true;