X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/34160ec4ec58f5ece2ef980201aee2fb20cfab46..a4cf101a98f1ea4d84b08a9c82a3b317ecacac03:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index ebb0c9be..0ba3af88 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])]) ## ----------------- ## @@ -182,6 +182,11 @@ 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]) @@ -228,6 +233,18 @@ b4_syncline([@oline@], [@ofile@])[ # define YYSIZE_T unsigned int #endif +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + #if ! defined (yyoverflow) || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -373,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. */ @@ -403,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[] = { @@ -412,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. */ @@ -517,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) @@ -597,7 +609,7 @@ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ + yysymprint (stderr, \ Type, Value]b4_location_if([, Location])[); \ YYFPRINTF (stderr, "\n"); \ } \ @@ -612,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"); @@ -633,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) \ @@ -728,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 */ @@ -859,16 +919,20 @@ b4_c_function_def([yyparse], [int], b4_parse_param) #endif ]]) m4_ifdef([b4_initial_action], [ -m4_pushdef([b4_at_dollar], [[yylsp[0]]])dnl -m4_pushdef([b4_dollar_dollar], [[yyvsp[0]]])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 -[ - goto yysetstate; +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; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | @@ -900,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),])[ @@ -911,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; @@ -925,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);])[ @@ -940,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; @@ -971,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 @@ -1004,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) @@ -1100,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; @@ -1112,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; @@ -1152,14 +1216,14 @@ 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); + yyf = YY_(yyformat); yysize1 = yysize + yystrlen (yyf); yysize_overflow |= yysize1 < yysize; yysize = yysize1; @@ -1177,7 +1241,7 @@ yyerrlab: { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { - yyp = yystpcpy (yyp, yyarg[yyi++]); + yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else @@ -1190,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;]])[ @@ -1206,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; } } @@ -1267,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); @@ -1285,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; @@ -1306,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);