bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: lalr1.cc: _


From: Akim Demaille
Subject: FYI: lalr1.cc: _
Date: Mon, 30 May 2005 07:25:57 -0000
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I'd like to have all the skeletons support the same set of features.
But I don't have much spare time :(  That's a first stab.

Paul, how about moving the error reporting code into a dedicated
function in yacc.c?  I'll do it if you agree.  That will also help
keep the skeletons more similar.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * data/lalr1.cc (_): New.
        Translate the various messages.

Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.85
diff -u -u -r1.85 lalr1.cc
--- data/lalr1.cc 22 May 2005 07:31:24 -0000 1.85
+++ data/lalr1.cc 30 May 2005 07:00:06 -0000
@@ -417,6 +417,11 @@
 [
 #include @address@hidden)[
 
+/* INFRINGES ON USER NAME SPACE */
+#ifndef _
+# define _(msgid) msgid
+#endif
+
 /* A pseudo ostream that takes yydebug_ into account. */
 # define YYCDEBUG                                                      \
   for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false)       
\
@@ -546,7 +551,7 @@
 {
   int yyresult_;
 
-  YYCDEBUG << "Starting parse" << std::endl;
+  YYCDEBUG << _("Starting parse") << std::endl;
 
   yynerrs_ = 0;
   yyerrstatus_ = 0;
@@ -578,7 +583,7 @@
   /* New state.  */
 yynewstate:
   yystate_stack_.push (yystate_);
-  YYCDEBUG << "Entering state " << yystate_ << std::endl;
+  YYCDEBUG << _("Entering state ") << yystate_ << std::endl;
   goto yybackup;
 
   /* Backup.  */
@@ -597,12 +602,12 @@
   if (yylooka_ <= yyeof_)
     {
       yylooka_ = yyilooka_ = yyeof_;
-      YYCDEBUG << "Now at end of input." << std::endl;
+      YYCDEBUG << _("Now at end of input.") << std::endl;
     }
   else
     {
       yyilooka_ = yytranslate_ (yylooka_);
-      YY_SYMBOL_PRINT ("Next token is", yyilooka_, &yylval, &yylloc);
+      YY_SYMBOL_PRINT (_("Next token is"), yyilooka_, &yylval, &yylloc);
     }
 
   /* If the proper action on seeing token ILOOKA_ is to reduce or to
@@ -631,7 +636,7 @@
     goto yyacceptlab;
 
   /* Shift the look-ahead token.  */
-  YY_SYMBOL_PRINT ("Shifting", yyilooka_, &yylval, &yylloc);
+  YY_SYMBOL_PRINT (_("Shifting"), yyilooka_, &yylval, &yylloc);
 
   /* Discard the token being shifted unless it is eof.  */
   if (yylooka_ != yyeof_)
@@ -729,7 +734,7 @@
                  yypop_ ();
                 if (yystate_stack_.height () == 1)
                   YYABORT;
-                 yydestruct_ ("Error: popping",
+                 yydestruct_ (_("Error: popping"),
                               yystos_[yystate_stack_[0]],
                               &yysemantic_stack_[0],
                               &yylocation_stack_[0]);
@@ -737,7 +742,7 @@
         }
       else
         {
-          yydestruct_ ("Error: discarding", yyilooka_, &yylval, &yylloc);
+          yydestruct_ (_("Error: discarding"), yyilooka_, &yylval, &yylloc);
           yylooka_ = yyempty_;
         }
     }
@@ -788,7 +793,7 @@
        YYABORT;
 
       yyerror_range_[0] = yylocation_stack_[0];
-      yydestruct_ ("Error: popping",
+      yydestruct_ (_("Error: popping"),
                    yystos_[yystate_],
                    &yysemantic_stack_[0], &yylocation_stack_[0]);
       yypop_ ();
@@ -807,7 +812,7 @@
   yylocation_stack_.push (yyloc);
 
   /* Shift the error token. */
-  YY_SYMBOL_PRINT ("Shifting", yystos_[yyn_],
+  YY_SYMBOL_PRINT (_("Shifting"), yystos_[yyn_],
                   &yysemantic_stack_[0], &yylocation_stack_[0]);
 
   yystate_ = yyn_;
@@ -825,14 +830,14 @@
 
 yyreturn:
   if (yylooka_ != yyeof_ && yylooka_ != yyempty_)
-    yydestruct_ ("Error: discarding lookahead", yyilooka_, &yylval, &yylloc);
+    yydestruct_ (_("Error: discarding lookahead"), yyilooka_, &yylval, 
&yylloc);
   return yyresult_;
 }
 
 void
 yy::]b4_parser_class_name[::yylex_ ()
 {
-  YYCDEBUG << "Reading a token: ";
+  YYCDEBUG << _("Reading a token: ");
 #if YYLSP_NEEDED
   yylooka_ = yylex (&yylval, &yylloc);
 #else
@@ -865,7 +870,7 @@
             if (yycheck_[x + yyn_] == x && x != yyterror_)
                ++count;
 
-         message = "syntax error, unexpected ";
+         message = _("syntax error, unexpected ");
          message += yyname_[yyilooka_];
           if (count < 5)
             {
@@ -873,14 +878,14 @@
               for (int x = yyxbegin; x < yyxend; ++x)
                 if (yycheck_[x + yyn_] == x && x != yyterror_)
                   {
-                    message += (!count++) ? ", expecting " : " or ";
+                    message += (!count++) ? _(", expecting ") : _(" or ");
                     message += yyname_[x];
                  }
             }
        }
       else
 #endif
-       message = "syntax error";
+       message = _("syntax error");
       error (yylloc, message);
     }
 }
@@ -1004,7 +1009,7 @@
 void
 yy::]b4_parser_class_name[::yystack_print_ ()
 {
-  *yycdebug_ << "Stack now";
+  *yycdebug_ << _("Stack now");
   for (state_stack_type::const_iterator i = yystate_stack_.begin ();
        i != yystate_stack_.end (); ++i)
     *yycdebug_ << ' ' << *i;
@@ -1017,8 +1022,8 @@
 {
   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]] << ' ';





reply via email to

[Prev in Thread] Current Thread [Next in Thread]