X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b4c1f9d2b647df6b70732d76bbf5bc9b21372e9a..4626a15dd155e1895262c48945a1c2b1d79b481f:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index b4885605..7af81941 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -1,4 +1,4 @@ -m4_divert(-1) -*- C -*- +m4_divert(-1) -*- C -*- # Yacc compatible skeleton for Bison @@ -36,10 +36,10 @@ m4_define_default([b4_stack_depth_init], [200]) ## ------------------------ ## -# b4_pure_if(IF-TRUE, IF-FALSE) -# ----------------------------- +# b4_yacc_pure_if(IF-TRUE, IF-FALSE) +# ---------------------------------- # Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise. -m4_define([b4_Pure_if], +m4_define([b4_yacc_pure_if], [b4_pure_if([m4_ifset([b4_parse_param], [$1], [$2])], [$2])]) @@ -49,7 +49,7 @@ m4_define([b4_Pure_if], # --------------- # Arguments passed to yyerror: user args plus yylloc. m4_define([b4_yyerror_args], -[b4_Pure_if([b4_location_if([&yylloc, ])])dnl +[b4_yacc_pure_if([b4_location_if([&yylloc, ])])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) @@ -219,18 +219,30 @@ typedef struct YYLTYPE /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])[ -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t +/* Define YYMODERN_C if this compiler supports C89 or better. If + __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run + as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic + reasons, but it defines __C99__FUNC__ so check that as well. + Consider a C++ compiler to be modern if it defines __cplusplus. */ +#ifndef YYMODERN_C +# if defined (__STDC__) || defined (__C99__FUNC__) || defined (__cplusplus) +# define YYMODERN_C 1 +# else +# define YYMODERN_C 0 +# endif #endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int + +#ifndef YYSIZE_T +# if defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +# elif defined (size_t) +# define YYSIZE_T size_t +# elif ! defined (YYSIZE_T) && YYMODERN_C +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) @@ -247,6 +259,9 @@ b4_syncline([@oline@], [@ofile@])[ # endif #endif +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) do {;} while (/*CONSTCOND*/ 0 && (e)) + #if ! defined (yyoverflow) || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -255,11 +270,20 @@ b4_syncline([@oline@], [@ofile@])[ # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# elif defined (__BUILTIN_VA_ARG_INCR) +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined (_AIX) +# define YYSTACK_ALLOC __alloca +# elif defined (_MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if defined (__STDC__) || defined (__cplusplus) +# if ! defined (_ALLOCA_H) && ! defined (_STDLIB_H) && YYMODERN_C # include /* INFRINGES ON USER NAME SPACE */ -# define YYINCLUDED_STDLIB_H +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif # endif # endif # endif @@ -286,15 +310,13 @@ extern "C" { # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) +# if ! defined (malloc) && ! defined (_STDLIB_H) && YYMODERN_C void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) +# if ! defined (free) && ! defined (_STDLIB_H) && YYMODERN_C void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -346,7 +368,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ - while (0) + while (/*CONSTCOND*/ 0) # endif # endif @@ -364,11 +386,11 @@ union yyalloc yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (0) + while (/*CONSTCOND*/ 0) #endif -#if defined (__STDC__) || defined (__cplusplus) +#if YYMODERN_C typedef signed char yysigned_char; #else typedef short int yysigned_char; @@ -535,7 +557,7 @@ do \ yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (0) +while (/*CONSTCOND*/ 0) #define YYTERROR 1 @@ -564,7 +586,7 @@ while (0) (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ - while (0) + while (/*CONSTCOND*/ 0) #endif @@ -604,18 +626,18 @@ while (0) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value]b4_location_if([, Location])[); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +} while (/*CONSTCOND*/ 0) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Type, Value]b4_location_if([, Location])[]b4_user_args[); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (/*CONSTCOND*/ 0) /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | @@ -636,7 +658,7 @@ do { \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (0) +} while (/*CONSTCOND*/ 0) /*------------------------------------------------. @@ -660,7 +682,7 @@ do { \ do { \ if (yydebug) \ yy_reduce_print (Rule); \ -} while (0) +} while (/*CONSTCOND*/ 0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -699,7 +721,7 @@ int yydebug; # else /* Return the length of YYSTR. */ static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) +# if YYMODERN_C yystrlen (const char *yystr) # else yystrlen (yystr) @@ -723,7 +745,7 @@ yystrlen (yystr) /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * -# if defined (__STDC__) || defined (__cplusplus) +# if YYMODERN_C yystpcpy (char *yydest, const char *yysrc) # else yystpcpy (yydest, yysrc) @@ -909,7 +931,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar) /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) +# if YYMODERN_C int yyparse (void *YYPARSE_PARAM); # else int yyparse (); @@ -947,7 +969,7 @@ b4_pure_if([], `----------*/ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) +# if YYMODERN_C int yyparse (void *YYPARSE_PARAM) # else int yyparse (YYPARSE_PARAM) @@ -1324,7 +1346,8 @@ yyerrlab: } else { - yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[); + yydestruct ("Error: discarding", + yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[); yychar = YYEMPTY; } } @@ -1342,7 +1365,7 @@ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ - if (0) + if (/*CONSTCOND*/ 0) goto yyerrorlab; ]b4_location_if([[ yyerror_range[0] = yylsp[1-yylen]; @@ -1378,7 +1401,8 @@ yyerrlab1: YYABORT; ]b4_location_if([[ yyerror_range[0] = *yylsp;]])[ - yydestruct ("Error: popping", yystos[yystate], yyvsp]b4_location_if([, yylsp])[); + yydestruct ("Error: popping", + yystos[yystate], yyvsp]b4_location_if([, yylsp])[]b4_user_args[); YYPOPSTACK; yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1429,11 +1453,11 @@ yyexhaustedlab: yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval]b4_location_if([, &yylloc])[); + yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[); + yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[]b4_user_args[); YYPOPSTACK; } #ifndef yyoverflow