]> git.saurik.com Git - bison.git/blobdiff - data/yacc.c
* configure.ac (AM_STDBOOL_H): Invoke this instead of AC_HEADER_STDBOOL.
[bison.git] / data / yacc.c
index 4ee09fbb3ae9027e3fc9cb971984c7885e00109e..1af5ec0b09c211e74cbab4d5683bdf576afb75ed 100644 (file)
@@ -248,7 +248,8 @@ b4_syncline([@oline@], [@ofile@])[
 
 #if (! defined (yyoverflow) \
      && (! defined (__cplusplus) \
-        || (]b4_location_if([YYLTYPE_IS_TRIVIAL && ])[YYSTYPE_IS_TRIVIAL)))
+        || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
+             && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
 
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
@@ -275,7 +276,7 @@ union yyalloc
 /* Copy COUNT objects from FROM to TO.  The source and destination do
    not overlap.  */
 # ifndef YYCOPY
-#  if 1 < __GNUC__
+#  if defined (__GNUC__) && 1 < __GNUC__
 #   define YYCOPY(To, From, Count) \
       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
 #  else
@@ -465,14 +466,7 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
 
 #define YYACCEPT       goto yyacceptlab
 #define YYABORT                goto yyabortlab
-#define YYERROR                ]b4_location_if([do                             \
-                         {                             \
-                           yylerrsp = yylsp;           \
-                           *++yylerrsp = yyloc;        \
-                           goto yyerrlab1;             \
-                         }                             \
-                       while (0)],
-                       [goto yyerrlab1])[
+#define YYERROR                goto yyerrorlab
 
 
 /* Like YYERROR except do call yyerror.  This remains here temporarily
@@ -1100,25 +1094,27 @@ yyerrlab:
       /* If just tried and failed to reuse lookahead token after an
         error, discard it.  */
 
-      /* Return failure if at end of input.  */
-      if (yychar == YYEOF)
+      if (yychar <= YYEOF)
         {
-         /* Pop the error token.  */
-          YYPOPSTACK;
-         /* Pop the rest of the stack.  */
-         while (yyss < yyssp)
-           {
-             YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
-             yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
-             YYPOPSTACK;
-           }
-         YYABORT;
+          /* If at end of input, pop the error token,
+            then the rest of the stack, then return failure.  */
+         if (yychar == YYEOF)
+            for (;;)
+              {
+                YYPOPSTACK;
+                if (yyssp == yyss)
+                  YYABORT;
+                YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
+                yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
+              }
         }
-
-      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
-      yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
-      yychar = YYEMPTY;
-]b4_location_if([      *++yylerrsp = yylloc;])[
+      else
+       {
+         YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
+         yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
+         yychar = YYEMPTY;
+]b4_location_if([        *++yylerrsp = yylloc;])[
+       }
     }
 
   /* Else will try to reuse lookahead token after shifting the error
@@ -1126,9 +1122,30 @@ yyerrlab:
   goto yyerrlab1;
 
 
-/*----------------------------------------------------.
-| yyerrlab1 -- error raised explicitly by an action.  |
-`----------------------------------------------------*/
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR.  |
+`---------------------------------------------------*/
+yyerrorlab:
+
+#ifdef __GNUC__
+  /* Pacify GCC when the user code never invokes YYERROR and the label
+     yyerrorlab therefore never appears in user code.  */
+  if (0)
+     goto yyerrorlab;
+#endif
+
+  yyvsp -= yylen;
+  yyssp -= yylen;
+  yystate = *yyssp;
+  ]b4_location_if([yylerrsp = yylsp;
+  *++yylerrsp = yyloc;
+  yylsp -= yylen;
+  ])[goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR.  |
+`-------------------------------------------------------------*/
 yyerrlab1:
   yyerrstatus = 3;     /* Each real token shifted decrements this.  */
 
@@ -1152,9 +1169,8 @@ yyerrlab1:
 
       YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
       yydestruct (yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
-      yyvsp--;
-      yystate = *--yyssp;
-]b4_location_if([      yylsp--;])[
+      YYPOPSTACK;
+      yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
     }