bison-patches
[Top][All Lists]
Advanced

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

Re: Bison 1.75c/d problem


From: Paul Eggert
Subject: Re: Bison 1.75c/d problem
Date: Sun, 15 Dec 2002 01:22:04 -0800 (PST)

> Date: Sat, 14 Dec 2002 14:47:40 +0000
> From: Andrew Walrond <address@hidden>
> 
> A standard bootstrap build of gcc 3.2.1 fails during configuration of 
> libstdc++-v3 with bison 1.75 c or d installed.
> 
> Works fine with vanilla bison 1.75

Thanks for the bug report.  I have installed the following patch,
which you can try now if you don't want to wait for the next Bison
test version.

2002-12-15  Paul Eggert  <address@hidden>

        Undo most of the 2002-11-12 yychar -> yytoken patch, as it broke
        GCC 3.2.1 (which depends on yychar == YYEMPTY when there is no
        lookahead symbol, and which sets yychar in parser actions) and it
        disagreed with the Bison documentation.  This should fix the bug
        reported by Andrew Walrond in
        <http://mail.gnu.org/pipermail/bug-bison/2002-December/001949.html>.
        
        * data/yacc.c (YYTRANSLATE): Don't check for negative argument,
        as the caller now does that.
        (yyclearin, YYBACKUP, yyparse): Use yychar, not yytoken.
        (YYEMPTY): Parenthesize right hand side, since others use it.
        (yyparse): Don't assume that our generated code is the only code
        that sets yychar.

--- data/yacc.c.~1.43.~ 2002-12-13 01:23:25.000000000 -0800
+++ data/yacc.c 2002-12-15 00:49:51.009001000 -0800
@@ -335,8 +335,7 @@ union yyalloc
 #define YYMAXUTOK   ]b4_user_token_number_max[
 
 #define YYTRANSLATE(YYX)                                               \
-  ((YYX <= 0) ? YYEOF :                                                        
\
-   (unsigned)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
 static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
@@ -462,8 +461,8 @@ static const ]b4_int_type_for([b4_stos])
 #endif
 
 #define yyerrok                (yyerrstatus = 0)
-#define yyclearin      (yytoken = YYEMPTY)
-#define YYEMPTY                -2
+#define yyclearin      (yychar = YYEMPTY)
+#define YYEMPTY                (-2)
 #define YYEOF          0
 
 #define YYACCEPT       goto yyacceptlab
@@ -480,7 +479,7 @@ static const ]b4_int_type_for([b4_stos])
 
 #define YYBACKUP(Token, Value)                                 \
 do                                                             \
-  if (yytoken == YYEMPTY && yylen == 1)                                \
+  if (yychar == YYEMPTY && yylen == 1)                         \
     {                                                          \
       yychar = (Token);                                                \
       yylval = (Value);                                                \
@@ -790,7 +789,7 @@ b4_c_function_def([yyparse], [int], b4_p
   yystate = 0;
   yyerrstatus = 0;
   yynerrs = 0;
-  yychar = yytoken = YYEMPTY;          /* Cause a token to be read.  */
+  yychar = YYEMPTY;            /* Cause a token to be read.  */
 
   /* Initialize stack pointers.
      Waste one element of value and location stack
@@ -900,20 +899,21 @@ yybackup:
 
   /* Not known => get a lookahead token if don't already have one.  */
 
-  /* YYTOKEN is either YYEMPTY or YYEOF or a valid token.  */
-  if (yytoken == YYEMPTY)
+  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
+  if (yychar == YYEMPTY)
     {
       YYDPRINTF ((stderr, "Reading a token: "));
       yychar = YYLEX;
-      yytoken = YYTRANSLATE (yychar);
     }
 
-  if (yytoken == YYEOF)
+  if (yychar <= YYEOF)
     {
+      yychar = yytoken = YYEOF;
       YYDPRINTF ((stderr, "Now at end of input.\n"));
     }
   else
     {
+      yytoken = YYTRANSLATE (yychar);
       YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
     }
 
@@ -938,8 +938,8 @@ yybackup:
   YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
 
   /* Discard the token being shifted unless it is eof.  */
-  if (yytoken != YYEOF)
-    yytoken = YYEMPTY;
+  if (yychar != YYEOF)
+    yychar = YYEMPTY;
 
   *++yyvsp = yylval;
 ]b4_location_if([  *++yylsp = yylloc;])[
@@ -1080,7 +1080,7 @@ yyerrlab:
         error, discard it.  */
 
       /* Return failure if at end of input.  */
-      if (yytoken == YYEOF)
+      if (yychar == YYEOF)
         {
          /* Pop the error token.  */
           YYPOPSTACK;
@@ -1096,7 +1096,7 @@ yyerrlab:
 
       YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
       yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
-      yytoken = YYEMPTY;
+      yychar = YYEMPTY;
     }
 
   /* Else will try to reuse lookahead token after shifting the error



reply via email to

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