X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b4a2033855c7d7838f8e079c0656d4e91bbb6361..cea1469d47457150f9643ef3e5c21154b0eba1db:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index 2e9c9fd0..07568b95 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -1,7 +1,8 @@ m4_divert(-1) -*- C -*- # Yacc compatible skeleton for Bison -# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 + +# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -16,8 +17,8 @@ m4_divert(-1) -*- C -*- # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA @@ -93,7 +94,7 @@ m4_define([b4_int_type], # -------------------- # Expansion of $$. m4_define([b4_lhs_value], -[yyval[]m4_ifval([$1], [.$1])]) +[(yyval[]m4_ifval([$1], [.$1]))]) # b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) @@ -101,7 +102,7 @@ m4_define([b4_lhs_value], # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], -[yyvsp@{m4_eval([$2 - $1])@}m4_ifval([$3], [.$3])]) +[(yyvsp@{m4_eval([$2 - $1])@}m4_ifval([$3], [.$3]))]) @@ -113,7 +114,7 @@ m4_define([b4_rhs_value], # ----------------- # Expansion of @$. m4_define([b4_lhs_location], -[yyloc]) +[(yyloc)]) # b4_rhs_location(RULE-LENGTH, NUM) @@ -121,7 +122,7 @@ m4_define([b4_lhs_location], # Expansion of @NUM, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], -[yylsp@{m4_eval([$2 - $1])@}]) +[(yylsp@{m4_eval([$2 - $1])@})]) @@ -134,7 +135,7 @@ m4_changecom() m4_divert(0)dnl @output @output_parser_name@ b4_copyright([Skeleton parser for Yacc-like parsing with Bison], - [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004])[ + [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005])[ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. @@ -153,8 +154,7 @@ b4_copyright([Skeleton parser for Yacc-like parsing with Bison], ]b4_identification m4_if(b4_prefix[], [yy], [], -[/* If NAME_PREFIX is specified substitute the variables and functions - names. */ +[/* Substitute the variable and function names. */ #define yyparse b4_prefix[]parse #define yylex b4_prefix[]lex #define yyerror b4_prefix[]error @@ -227,14 +227,10 @@ b4_syncline([@oline@], [@ofile@])[ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# endif -# else -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# else +# define YYSTACK_ALLOC alloca # endif # endif # endif @@ -242,13 +238,25 @@ b4_syncline([@oline@], [@ofile@])[ # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# 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 # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ @@ -290,7 +298,7 @@ union yyalloc # define YYCOPY(To, From, Count) \ do \ { \ - register YYSIZE_T yyi; \ + YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ @@ -379,6 +387,11 @@ 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. */ @@ -496,7 +509,7 @@ do \ } \ else \ { \ - yyerror (]b4_yyerror_args["syntax error: cannot back up");\ + yyerror (]b4_yyerror_args[_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) @@ -510,22 +523,25 @@ while (0) If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ -do { \ - if (N) \ - { \ - (Current).first_line = (Rhs)[1].first_line; \ - (Current).first_column = (Rhs)[1].first_column; \ - (Current).last_line = (Rhs)[N].last_line; \ - (Current).last_column = (Rhs)[N].last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = (Rhs)[0].last_line; \ - (Current).first_column = (Current).last_column = (Rhs)[0].last_column; \ - } \ -} while(0) +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) #endif @@ -587,7 +603,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"); @@ -609,7 +625,7 @@ do { \ { int yyi; unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + YYFPRINTF (stderr, _("Reducing stack by rule %d (line %u), "), yyrule - 1, yylno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) @@ -643,13 +659,9 @@ int yydebug; if the built-in stack extension method is used). Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - #ifndef YYMAXDEPTH # define YYMAXDEPTH ]b4_stack_depth_max[ #endif @@ -671,7 +683,7 @@ yystrlen (yystr) const char *yystr; # endif { - register const char *yys = yystr; + const char *yys = yystr; while (*yys++ != '\0') continue; @@ -696,8 +708,8 @@ yystpcpy (yydest, yysrc) const char *yysrc; # endif { - register char *yyd = yydest; - register const char *yys = yysrc; + char *yyd = yydest; + const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; @@ -769,8 +781,8 @@ b4_c_function_def([yyparse], [int], b4_parse_param) #endif {[ ]b4_pure_if([b4_declare_parser_variables])[ - register int yystate; - register int yyn; + int yystate; + int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; @@ -788,12 +800,12 @@ b4_c_function_def([yyparse], [int], b4_parse_param) /* The state stack. */ short int yyssa[YYINITDEPTH]; short int *yyss = yyssa; - register short int *yyssp; + short int *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; + YYSTYPE *yyvsp; ]b4_location_if( [[ /* The location stack. */ @@ -841,7 +853,7 @@ m4_ifdef([b4_initial_action], [ m4_pushdef([b4_at_dollar], [yylloc])dnl m4_pushdef([b4_dollar_dollar], [yylval])dnl /* User initialization code. */ - b4_initial_action +b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl /* Line __line__ of yacc.c. */ @@ -882,7 +894,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 (_("parser stack overflow"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), ]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[ @@ -922,14 +934,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; @@ -953,19 +965,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 @@ -986,7 +998,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) @@ -1038,6 +1050,7 @@ yyreduce: switch (yyn) ]{ b4_actions + default: break; } /* Line __line__ of yacc.c. */ @@ -1080,12 +1093,36 @@ yyerrlab: if (YYPACT_NINF < yyn && yyn < YYLAST) { - YYSIZE_T yysize = 0; int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; + YYSIZE_T yysize0 = yystrlen (yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + char *yymsg = 0; +# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; int yyx; +#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"); +#endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; @@ -1093,48 +1130,65 @@ yyerrlab: /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); - yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { - yysize = 0; + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; break; } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yystrlen (yytname[yyx]); + yysize_overflow |= yysize1 < yysize; + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - if (yycount < 5) + yyf = _(yyformat); + yysize1 = yysize + strlen (yyf); + yysize_overflow |= yysize1 < yysize; + yysize = yysize1; + + if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yymsg; + int yyi = 0; + while ((*yyp = *yyf)) { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; - } + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp = yystpcpy (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } } yyerror (]b4_yyerror_args[yymsg); YYSTACK_FREE (yymsg); } else - yyerror (]b4_yyerror_args["syntax error; also virtual memory exhausted"); + yyerror (]b4_yyerror_args[_("syntax error; also memory exhausted")); } else #endif /* YYERROR_VERBOSE */ - yyerror (]b4_yyerror_args["syntax error"); + yyerror (]b4_yyerror_args[_("syntax error")); } ]b4_location_if([[ yyerror_range[0] = yylloc;]])[ @@ -1149,19 +1203,11 @@ yyerrlab: /* If at end of input, pop the error token, then the rest of the stack, then return failure. */ if (yychar == YYEOF) - for (;;) - { -]b4_location_if([[ yyerror_range[0] = *yylsp;]])[ - YYPOPSTACK; - if (yyssp == yyss) - YYABORT; - yydestruct ("Error: popping", - yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[); - } + YYABORT; } else { - yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[); + yydestruct (_("Error: discarding"), yytoken, &yylval]b4_location_if([, &yylloc])[); yychar = YYEMPTY; } } @@ -1176,12 +1222,11 @@ yyerrlab: `---------------------------------------------------*/ yyerrorlab: -#ifdef __GNUC__ - /* Pacify GCC when the user code never invokes YYERROR and the label - yyerrorlab therefore never appears in user code. */ + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ if (0) goto yyerrorlab; -#endif ]b4_location_if([[ yyerror_range[0] = yylsp[1-yylen]; yylsp -= yylen; @@ -1216,7 +1261,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); @@ -1234,7 +1279,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; @@ -1251,9 +1296,6 @@ yyacceptlab: | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: - yydestruct ("Error: discarding lookahead", - yytoken, &yylval]b4_location_if([, &yylloc])[); - yychar = YYEMPTY; yyresult = 1; goto yyreturn; @@ -1262,12 +1304,25 @@ yyabortlab: | yyoverflowlab -- parser overflow comes here. | `----------------------------------------------*/ yyoverflowlab: - yyerror (]b4_yyerror_args["parser stack overflow"); + yyerror (]b4_yyerror_args[_("parser stack overflow")); yyresult = 2; /* Fall through. */ #endif yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct (_("Error: 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])[); + } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); @@ -1280,7 +1335,7 @@ b4_epilogue m4_if(b4_defines_flag, 0, [], [@output @output_header_name@ b4_copyright([Skeleton parser for Yacc-like parsing with Bison], - [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004]) + [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005]) /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction.