]> git.saurik.com Git - bison.git/blobdiff - data/lalr1.cc
Update copyright.
[bison.git] / data / lalr1.cc
index 746054beba489ef0c2f903396aa783431e46ca93..e42a2e5da9a2148ecbd5acf8d754d5d1cb6d9a15 100644 (file)
@@ -16,8 +16,8 @@ m4_divert(-1)
 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-# 02111-1307  USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301  USA
 
 ## ---------------- ##
 ## Default values.  ##
@@ -115,7 +115,7 @@ m4_divert(0)dnl
 m4_if(b4_defines_flag, 0, [],
 [@output @output_header_name@
 b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
-             [2002, 2003, 2004])[
+             [2002, 2003, 2004, 2005])[
 /* FIXME: This is wrong, we want computed header guards.
    I don't know why the macros are missing now. :( */
 #ifndef PARSER_HEADER_H
@@ -408,7 +408,7 @@ namespace yy
 ])dnl
 @output @output_parser_name@
 b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
-             [2002, 2003, 2004])
+             [2002, 2003, 2004, 2005])
 m4_if(b4_prefix[], [yy], [],
 [
 // Take the name prefix into account.
@@ -417,6 +417,18 @@ m4_if(b4_defines_flag, 0, [],
 [
 #include @output_header_name@])[
 
+#ifndef YY_
+# if YYENABLE_NLS
+#  if ENABLE_NLS
+#   include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
+#   define YY_(msgid) dgettext ("bison-runtime", msgid)
+#  endif
+# endif
+# ifndef YY_
+#  define YY_(msgid) msgid
+# endif
+#endif
+
 /* A pseudo ostream that takes yydebug_ into account. */
 # define YYCDEBUG                                                      \
   for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false)       \
@@ -544,6 +556,8 @@ yy::]b4_parser_class_name[::set_debug_level (debug_level_type l)
 int
 yy::]b4_parser_class_name[::parse ()
 {
+  int yyresult_;
+
   YYCDEBUG << "Starting parse" << std::endl;
 
   yynerrs_ = 0;
@@ -679,6 +693,7 @@ yyreduce:
   switch (yyn_)
     {
       ]b4_actions[
+      default: break;
     }
 
 ]/* Line __line__ of lalr1.cc.  */
@@ -812,25 +827,28 @@ yyerrlab1:
 
   /* Accept.  */
 yyacceptlab:
-  return 0;
+  yyresult_ = 0;
+  goto yyreturn;
 
   /* Abort.  */
 yyabortlab:
-  /* Free the lookahead. */
-  yydestruct_ ("Error: discarding lookahead", yyilooka_, &yylval, &yylloc);
-  yylooka_ = yyempty_;
-  return 1;
+  yyresult_ = 1;
+  goto yyreturn;
+
+yyreturn:
+  if (yylooka_ != yyeof_ && yylooka_ != yyempty_)
+    yydestruct_ ("Error: discarding lookahead", yyilooka_, &yylval, &yylloc);
+  return yyresult_;
 }
 
 void
 yy::]b4_parser_class_name[::yylex_ ()
 {
   YYCDEBUG << "Reading a token: ";
-#if YYLSP_NEEDED
-  yylooka_ = yylex (&yylval, &yylloc);
-#else
-  yylooka_ = yylex (&yylval);
-#endif
+  yylooka_ = ]b4_c_function_call([yylex], [int],
+[[YYSTYPE*], [&yylval]][]dnl
+b4_location_if([, [[location*], [&yylloc]]])dnl
+m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
 }
 
 // Generate an error message, and invoke error.
@@ -858,6 +876,14 @@ yy::]b4_parser_class_name[::yyreport_syntax_error_ ()
             if (yycheck_[x + yyn_] == x && x != yyterror_)
               ++count;
 
+         // FIXME: This method of building the message is not compatible
+         // with internationalization.  It should work like yacc.c does it.
+         // That is, first build a string that looks like this:
+         // "syntax error, unexpected %s or %s or %s"
+         // Then, invoke YY_ on this string.
+         // Finally, use the string as a format to output
+         // yyname_[yyilooka_], etc.
+         // Until this gets fixed, this message appears in English only.
          message = "syntax error, unexpected ";
          message += yyname_[yyilooka_];
           if (count < 5)
@@ -873,7 +899,7 @@ yy::]b4_parser_class_name[::yyreport_syntax_error_ ()
        }
       else
 #endif
-       message = "syntax error";
+       message = YY_("syntax error");
       error (yylloc, message);
     }
 }
@@ -1010,8 +1036,8 @@ yy::]b4_parser_class_name[::yyreduce_print_ (int yyrule)
 {
   unsigned int yylno = yyrline_[yyrule];
   /* Print the symbols being reduced, and their result.  */
-    *yycdebug_ << "Reducing stack by rule " << yyn_ - 1
-               << " (line " << yylno << "), ";
+  *yycdebug_ << "Reducing stack by rule " << yyn_ - 1
+             << " (line " << yylno << "), ";
   for (]b4_int_type_for([b4_prhs])[ i = yyprhs_[yyn_];
        0 <= yyrhs_[i]; ++i)
     *yycdebug_ << yyname_[yyrhs_[i]] << ' ';
@@ -1050,7 +1076,7 @@ const yy::]b4_parser_class_name[::token_number_type yy::]b4_parser_class_name[::
 ]b4_epilogue
 dnl
 @output stack.hh
-b4_copyright([stack handling for Bison C++ parsers], [2002, 2003, 2004])[
+b4_copyright([stack handling for Bison C++ parsers], [2002, 2003, 2004, 2005])[
 
 #ifndef BISON_STACK_HH
 # define BISON_STACK_HH
@@ -1149,7 +1175,7 @@ namespace yy
 #endif // not BISON_STACK_HH]
 dnl
 @output position.hh
-b4_copyright([Position class for Bison C++ parsers], [2002, 2003, 2004])[
+b4_copyright([Position class for Bison C++ parsers], [2002, 2003, 2004, 2005])[
 
 /**
  ** \file position.hh
@@ -1262,7 +1288,7 @@ namespace yy
 }
 #endif // not BISON_POSITION_HH]
 @output location.hh
-b4_copyright([Location class for Bison C++ parsers], [2002, 2003, 2004])[
+b4_copyright([Location class for Bison C++ parsers], [2002, 2003, 2004, 2005])[
 
 /**
  ** \file location.hh