]> git.saurik.com Git - bison.git/blobdiff - data/yacc.c
* data/yacc.c: Guard the declaration of yytoknum also with
[bison.git] / data / yacc.c
index a4483609dd48c3c5c3598e1ee1a75e891c747704..daa08d60dad3c644398b3ec19e511b3ae47cbf32 100644 (file)
@@ -358,12 +358,14 @@ static const char *const yytname[[]] =
 };
 #endif
 
+# ifdef YYPRINT
 /* YYTOKNUM[[YYLEX-NUM]] -- Internal token number corresponding to
    token YYLEX-NUM.  */
 static const b4_int_type_for([b4_toknum]) yytoknum[[]] =
 {
   b4_toknum
 };
+# endif
 
 /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives.  */
 static const b4_int_type_for([b4_r1]) yyr1[[]] =
@@ -603,52 +605,17 @@ yystpcpy (yydest, yysrc)
 
 \f
 
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
-   into yyparse.  The argument should have type void *.
-   It should actually point to an object.
-   Grammar actions can access the variable by casting it
-   to the proper pointer type.  */
-
-#ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
-#  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#  define YYPARSE_PARAM_DECL
-# else
-#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-# endif
-#else /* !YYPARSE_PARAM */
-# define YYPARSE_PARAM_ARG
-# define YYPARSE_PARAM_DECL
-#endif /* !YYPARSE_PARAM */
-
-/* Prevent warning if -Wstrict-prototypes.  */
-#ifdef __GNUC__
-# ifdef YYPARSE_PARAM
-int yyparse (void *);
-# else
-int yyparse (void);
-# endif
-#endif
-
-
 #if YYDEBUG
 /*-----------------------------.
 | Print this symbol on YYOUT.  |
 `-----------------------------*/
 
-static void
-#if defined (__STDC__) || defined (__cplusplus)
-yysymprint (FILE* yyout, int yytype,
-           YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
-#else
-yysymprint (yyout, yytype,
-           yyvalue[]b4_location_if([, yylocation]))
-  FILE* yyout;
-  int yytype;
-  YYSTYPE yyvalue;
-  b4_location_if([YYLTYPE yylocation;])
-#endif
+b4_c_function([yysymprint],
+             [static void],
+             [[FILE*],   [yyout]],
+             [[int],     [yytype]],
+             [[YYSTYPE], [yyvalue]]b4_location_if([,
+             [[YYLTYPE], [yylocation]]]))
 {
   /* Pacify ``unused variable'' warnings.  */
   (void) yyvalue;
@@ -680,18 +647,12 @@ m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
 | yyreport_parse_error -- report a parse error in YYSTATE.  |
 `----------------------------------------------------------*/
 
-static void
-#if defined (__STDC__) || defined (__cplusplus)
-yyreport_parse_error (int yystate, int yychar,
-                     YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
-#else
-yyreport_parse_error (yystate, yychar,
-                     yyvalue[]b4_location_if([, yylocation]))
-  int yystate;
-  int yychar;
-  YYSTYPE yyvalue;
-  b4_location_if([YYLTYPE yylocation;])
-#endif
+b4_c_function([yyreport_parse_error],
+             [static void],
+             [[int],     [yystate]],
+             [[int],     [yychar]],
+             [[YYSTYPE], [yyvalue]]b4_location_if([,
+             [[YYLTYPE], [yylloc]]]))
 [{
 #if YYERROR_VERBOSE
   int yyn = yypact[yystate];
@@ -708,7 +669,7 @@ yyreport_parse_error (yystate, yychar,
         YYCHECK.  */
       for (yyx = yyn < 0 ? -yyn : 0;
           yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
-       if (yycheck[yyx + yyn] == yyx)
+       if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
          yysize += yystrlen (yytname[yyx]) + 15, yycount++;
       yysize += yystrlen ("parse error, unexpected ") + 1;
       yysize += yystrlen (yytname[yytype]);
@@ -724,7 +685,7 @@ yyreport_parse_error (yystate, yychar,
              for (yyx = yyn < 0 ? -yyn : 0;
                   yyx < (int) (sizeof (yytname) / sizeof (char *));
                   yyx++)
-               if (yycheck[yyx + yyn] == yyx)
+               if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
                  {
                    const char *yyq = ! yycount ? ", expecting " : " or ";
                    yyp = yystpcpy (yyp, yyq);
@@ -746,7 +707,7 @@ yyreport_parse_error (yystate, yychar,
   (void) yystate;
   (void) yychar;
   (void) yyvalue;
-  ]b4_location_if([(void) yylocation;])[
+  ]b4_location_if([(void) yylloc;])[
 }]
 
 
@@ -754,17 +715,11 @@ yyreport_parse_error (yystate, yychar,
 | Release the memory associated to this symbol.  |
 `-----------------------------------------------*/
 
-static void
-#if defined (__STDC__) || defined (__cplusplus)
-yydestruct (int yytype,
-           YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
-#else
-yydestruct (yytype,
-           yyvalue[]b4_location_if([, yylocation]))
-  int yytype;
-  YYSTYPE yyvalue;
-  b4_location_if([YYLTYPE yylocation;])
-#endif
+b4_c_function([yydestruct],
+             [static void],
+             [[int],     [yytype]],
+             [[YYSTYPE], [yyvalue]]b4_location_if([,
+             [[YYLTYPE], [yylocation]]]))
 {
   /* Pacify ``unused variable'' warnings.  */
   (void) yyvalue;
@@ -779,6 +734,35 @@ m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))dnl
     }
 }
 
+\f
+
+/* The user can define YYPARSE_PARAM as the name of an argument to be passed
+   into yyparse.  The argument should have type void *.
+   It should actually point to an object.
+   Grammar actions can access the variable by casting it
+   to the proper pointer type.  */
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+#  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
+#  define YYPARSE_PARAM_DECL
+# else
+#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
+#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
+# endif
+#else /* !YYPARSE_PARAM */
+# define YYPARSE_PARAM_ARG
+# define YYPARSE_PARAM_DECL
+#endif /* !YYPARSE_PARAM */
+
+/* Prevent warning if -Wstrict-prototypes.  */
+#ifdef __GNUC__
+# ifdef YYPARSE_PARAM
+int yyparse (void *);
+# else
+int yyparse (void);
+# endif
+#endif
 
 m4_divert_push([KILL])# ======================== M4 code.
 # b4_declare_parser_variables
@@ -1062,8 +1046,8 @@ yyreduce:
   /* If YYLEN is nonzero, implement the default value of the action:
      `$$ = $1'.
 
-     Otherwise, the following line sets YYVAL to the semantic value of
-     the lookahead token.  This behavior is undocumented and Bison
+     Otherwise, the following line sets YYVAL to garbage.
+     This behavior is undocumented and Bison
      users should not rely upon it.  Assigning to YYVAL
      unconditionally makes the parser a bit smaller, and it avoids a
      GCC warning that YYVAL may be used uninitialized.  */