]> git.saurik.com Git - bison.git/blobdiff - data/lalr1.cc
Update copyright.
[bison.git] / data / lalr1.cc
index eef5a13c3b4cae58121e07de529f09f197093dd3..e42a2e5da9a2148ecbd5acf8d754d5d1cb6d9a15 100644 (file)
@@ -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)       \
@@ -833,11 +845,10 @@ 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.
@@ -865,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)
@@ -880,7 +899,7 @@ yy::]b4_parser_class_name[::yyreport_syntax_error_ ()
        }
       else
 #endif
-       message = "syntax error";
+       message = YY_("syntax error");
       error (yylloc, message);
     }
 }
@@ -1017,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]] << ' ';