X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/cea1469d47457150f9643ef3e5c21154b0eba1db..1bd0dedaaa08858f4ad13a11a75d814fd7ceb5ce:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index 07568b95..7e7c44ac 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -82,7 +82,7 @@ m4_define([b4_int_type], m4_eval([0 <= $1]), [1], [unsigned int], - [int])]) + [int])]) ## ----------------- ## @@ -164,7 +164,7 @@ m4_if(b4_prefix[], [yy], [], #define yynerrs b4_prefix[]nerrs b4_location_if([#define yylloc b4_prefix[]lloc])])[ -]b4_token_defines(b4_tokens)[ +]b4_token_enums_defines(b4_tokens)[ /* Copy the first part of user declarations. */ ]b4_pre_prologue[ @@ -182,9 +182,14 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[ # define YYERROR_VERBOSE ]b4_error_verbose[ #endif +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE ]b4_token_table[ +#endif + #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_filename]) +[b4_syncline([b4_stype_line], [b4_file_name]) typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])], @@ -214,14 +219,33 @@ typedef struct YYLTYPE /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])[ -#if ! defined (yyoverflow) || YYERROR_VERBOSE +#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 +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif -# ifndef YYFREE -# define YYFREE free +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif # endif -# ifndef YYMALLOC -# define YYMALLOC malloc +# ifndef YY_ +# define YY_(msgid) msgid # endif +#endif + +#if ! defined (yyoverflow) || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -231,6 +255,10 @@ b4_syncline([@oline@], [@ofile@])[ # define YYSTACK_ALLOC __builtin_alloca # else # define YYSTACK_ALLOC alloca +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYINCLUDED_STDLIB_H +# endif # endif # endif # endif @@ -246,17 +274,31 @@ b4_syncline([@oline@], [@ofile@])[ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ # endif # else -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned long int -# endif # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) # endif +# ifdef __cplusplus +extern "C" { +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ + && (defined (__STDC__) || defined (__cplusplus))) +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))) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifdef __cplusplus +} +# endif # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ @@ -348,7 +390,7 @@ union yyalloc #define YYUNDEFTOK ]b4_undef_token_number[ #define YYMAXUTOK ]b4_user_token_number_max[ -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ @@ -378,8 +420,8 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { @@ -387,11 +429,6 @@ static const char *const yytname[] = }; #endif -/* INFRINGES ON USER NAME SPACE */ -#ifndef _ -# define _(msgid) msgid -#endif - # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ @@ -463,22 +500,6 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] = ]b4_stos[ }; -#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) -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) @@ -508,8 +529,8 @@ do \ goto yybackup; \ } \ else \ - { \ - yyerror (]b4_yyerror_args[_("syntax error: cannot back up")); \ + { \ + yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) @@ -588,7 +609,7 @@ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ + yysymprint (stderr, \ Type, Value]b4_location_if([, Location])[); \ YYFPRINTF (stderr, "\n"); \ } \ @@ -603,7 +624,7 @@ do { \ [[short int *bottom], [bottom]], [[short int *top], [top]])[ { - YYFPRINTF (stderr, _("Stack now")); + YYFPRINTF (stderr, "Stack now"); for (/* Nothing. */; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); @@ -624,13 +645,13 @@ do { \ [[int yyrule], [yyrule]])[ { int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, _("Reducing stack by rule %d (line %u), "), + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", yyrule - 1, yylno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); } # define YY_REDUCE_PRINT(Rule) \ @@ -719,7 +740,55 @@ yystpcpy (yydest, yysrc) # endif # endif -#endif /* !YYERROR_VERBOSE */ +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + size_t yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +#endif /* YYERROR_VERBOSE */ @@ -850,18 +919,19 @@ b4_c_function_def([yyparse], [int], b4_parse_param) #endif ]]) m4_ifdef([b4_initial_action], [ -m4_pushdef([b4_at_dollar], [yylloc])dnl -m4_pushdef([b4_dollar_dollar], [yylval])dnl +m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl +m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl /* User initialization code. */ b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl /* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@])])dnl -[ - yyvsp[0] = yylval; -]b4_location_if([[ yylsp[0] = yylloc; -]]) +b4_syncline([@oline@], [@ofile@]) +])dnl +m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval; +]])dnl +m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; +]])dnl [ goto yysetstate; /*------------------------------------------------------------. @@ -894,7 +964,7 @@ b4_syncline([@oline@], [@ofile@])])dnl data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ - yyoverflow (_("parser stack overflow"), + yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), ]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[ @@ -905,11 +975,11 @@ b4_syncline([@oline@], [@ofile@])])dnl } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE - goto yyoverflowlab; + goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; @@ -919,7 +989,7 @@ b4_syncline([@oline@], [@ofile@])])dnl union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) - goto yyoverflowlab; + goto yyexhaustedlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); ]b4_location_if([ YYSTACK_RELOCATE (yyls);])[ @@ -934,14 +1004,14 @@ b4_syncline([@oline@], [@ofile@])])dnl yyvsp = yyvs + yysize - 1; ]b4_location_if([ yylsp = yyls + yysize - 1;])[ - YYDPRINTF ((stderr, _("Stack size increased to %lu\n"), + YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - YYDPRINTF ((stderr, _("Entering state %d\n"), yystate)); + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; @@ -965,19 +1035,19 @@ yybackup: /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, _("Reading a token: "))); + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, _("Now at end of input.\n"))); + YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT (_("Next token is"), yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to @@ -998,7 +1068,7 @@ yybackup: YYACCEPT; /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT (_("Shifting"), yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) @@ -1094,7 +1164,7 @@ yyerrlab: if (YYPACT_NINF < yyn && yyn < YYLAST) { int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yystrlen (yytname[yytype]); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; int yysize_overflow = 0; @@ -1106,11 +1176,11 @@ yyerrlab: #if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ - _("syntax error, unexpected %s"); - _("syntax error, unexpected %s, expecting %s"); - _("syntax error, unexpected %s, expecting %s or %s"); - _("syntax error, unexpected %s, expecting %s or %s or %s"); - _("syntax error, unexpected %s, expecting %s or %s or %s or %s"); + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); #endif char *yyfmt; char const *yyf; @@ -1146,15 +1216,15 @@ yyerrlab: break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yystrlen (yytname[yyx]); + yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize_overflow |= yysize1 < yysize; yysize = yysize1; yyfmt = yystpcpy (yyfmt, yyprefix); yyprefix = yyor; } - yyf = _(yyformat); - yysize1 = yysize + strlen (yyf); + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); yysize_overflow |= yysize1 < yysize; yysize = yysize1; @@ -1171,7 +1241,7 @@ yyerrlab: { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { - yyp = yystpcpy (yyp, yyarg[yyi++]); + yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else @@ -1184,11 +1254,14 @@ yyerrlab: YYSTACK_FREE (yymsg); } else - yyerror (]b4_yyerror_args[_("syntax error; also memory exhausted")); + { + yyerror (]b4_yyerror_args[YY_("syntax error")); + goto yyexhaustedlab; + } } else #endif /* YYERROR_VERBOSE */ - yyerror (]b4_yyerror_args[_("syntax error")); + yyerror (]b4_yyerror_args[YY_("syntax error")); } ]b4_location_if([[ yyerror_range[0] = yylloc;]])[ @@ -1200,14 +1273,13 @@ yyerrlab: if (yychar <= YYEOF) { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ + /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { - yydestruct (_("Error: discarding"), yytoken, &yylval]b4_location_if([, &yylloc])[); + yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[); yychar = YYEMPTY; } } @@ -1261,7 +1333,7 @@ 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])[); YYPOPSTACK; yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1279,7 +1351,7 @@ yyerrlab1: *++yylsp = yyloc;]])[ /* Shift the error token. */ - YY_SYMBOL_PRINT (_("Shifting"), yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -1300,29 +1372,25 @@ yyabortlab: goto yyreturn; #ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror (]b4_yyerror_args[_("parser stack overflow")); +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (]b4_yyerror_args[YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct (_("Error: discarding lookahead"), + yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval]b4_location_if([, &yylloc])[); - if (yyssp != yyss) - for (;;) - { -]b4_location_if([[ yyerror_range[0] = *yylsp;]])[ - YYPOPSTACK; - if (yyssp == yyss) - break; - yydestruct (_("Error: popping"), - yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[); - } + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[); + YYPOPSTACK; + } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); @@ -1342,11 +1410,11 @@ b4_copyright([Skeleton parser for Yacc-like parsing with Bison], This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ -b4_token_defines(b4_tokens) +b4_token_enums_defines(b4_tokens) #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_filename]) +[b4_syncline([b4_stype_line], [b4_file_name]) typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])],