X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/08af01c2fc26eeb77afe3a667dded68c52ea3c37..f57a753663ecb42c6c261a7542e28695b920fb70:/data/push.c diff --git a/data/push.c b/data/push.c index 25010509..ee9aa671 100644 --- a/data/push.c +++ b/data/push.c @@ -33,7 +33,6 @@ b4_use_push_for_pull_if([ ])]) m4_include(b4_pkgdatadir/[c.m4]) -b4_check_percent_code_qualifiers([[requires]], [[provides]], [[top]]) ## ---------------- ## ## Default values. ## @@ -161,9 +160,7 @@ b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl ' USER NAME SPACE" below. */ ]b4_identification -m4_ifdef([b4_percent_code_top], -[[/* Copy the %code "top" blocks. */ -]b4_user_code([b4_percent_code_top])])[]dnl +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [[/* Substitute the variable and function names. */ ]b4_pull_if([[#define yyparse ]b4_prefix[parse @@ -201,17 +198,16 @@ m4_if(b4_prefix, [yy], [], # define YYTOKEN_TABLE ]b4_token_table[ #endif -]m4_ifdef([b4_percent_code_requires], -[[/* Copy the %code "requires" blocks. */ -]b4_user_code([b4_percent_code_requires])])[]dnl +]b4_percent_code_get([[requires]])[]dnl b4_token_enums_defines(b4_tokens)[ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED ]m4_ifdef([b4_stype], [[typedef union ]b4_union_name[ +{ ]b4_user_stype[ - YYSTYPE; +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1]], [m4_if(b4_tag_seen_flag, 0, [[typedef int YYSTYPE; @@ -254,16 +250,11 @@ b4_c_function_decl([[yypstate_delete]], [[void]], [[[yypstate *yyps]], [[yyps]]])[ #endif ]]) -m4_ifdef([b4_percent_code_provides], -[[/* Copy the %code "provides" blocks. */ -]b4_user_code([b4_percent_code_provides])])[]dnl +b4_percent_code_get([[provides]])[]dnl [/* Copy the second part of user declarations. */ ]b4_user_post_prologue -m4_ifdef([b4_percent_code], -[[/* Copy the unqualified %code blocks. */ -]b4_user_code([b4_percent_code]) -])[]dnl +b4_percent_code_get[]dnl [#ifdef short # undef short @@ -341,7 +332,8 @@ typedef short int yytype_int16; #if ! defined yyoverflow || YYERROR_VERBOSE -/* The parser invokes alloca or malloc; define the necessary symbols. */ +]b4_push_if([], +[[/* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA @@ -366,7 +358,8 @@ typedef short int yytype_int16; # endif # endif -# ifdef YYSTACK_ALLOC +]])dnl +[# ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM @@ -757,12 +750,12 @@ do { \ /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &]b4_rhs_value(yynrhs, yyi + 1)[ ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl b4_user_args[); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1098,13 +1091,20 @@ b4_push_if( ]b4_locations_if([[ YYLTYPE yylloc; ]])])[ if (yyps == 0) - yyps_local = yypstate_new (); - else - yyps_local = yyps; - do { - yychar = YYLEX; - yystatus = - yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[); + { + yyps_local = yypstate_new (); + if (!yyps_local) + { + yyerror (]b4_yyerror_args[YY_("memory exhausted")); + return 2; + } + } + else + yyps_local = yyps; + do { + yychar = YYLEX; + yystatus = + yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[); } while (yystatus == YYPUSH_MORE); if (yyps == 0) yypstate_delete (yyps_local); @@ -1115,6 +1115,8 @@ b4_push_if( ]b4_c_function_def([[yypstate_new]], [[yypstate *]])[ { yypstate *yyps = (yypstate *) malloc (sizeof *yyps); + if (!yyps) + return 0; yyps->yynew = 1; return yyps; } @@ -1158,8 +1160,8 @@ b4_c_function_def([yyparse], [int], [[void *YYPARSE_PARAM], [YYPARSE_PARAM]]) b4_c_function_def([yyparse], [int], b4_parse_param) #endif])[ { - ]b4_pure_if([b4_declare_scanner_communication_variables]) - b4_push_if([b4_pure_if([], [[ int yypushed_char = yychar; +]b4_pure_if([b4_declare_scanner_communication_variables]) +b4_push_if([b4_pure_if([], [[ int yypushed_char = yychar; YYSTYPE yypushed_val = yylval; ]b4_locations_if([[YYLTYPE yypushed_loc = yylloc; ]])])], @@ -1663,17 +1665,16 @@ b4_defines_if( b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) -m4_ifdef([b4_percent_code_requires], -[[/* Copy the %code "requires" blocks. */ -]b4_user_code([b4_percent_code_requires])])[]dnl +b4_percent_code_get([[requires]])[]dnl b4_token_enums_defines(b4_tokens) [#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED ]m4_ifdef([b4_stype], [[typedef union ]b4_union_name[ +{ ]b4_user_stype[ - YYSTYPE; +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1]], [m4_if(b4_tag_seen_flag, 0, [[typedef int YYSTYPE; @@ -1722,8 +1723,6 @@ b4_c_function_decl([b4_prefix[pstate_delete]], [[void]], [[b4_prefix[pstate *yyps]], [[yyps]]])[ #endif ]]) -m4_ifdef([b4_percent_code_provides], -[[/* Copy the %code "provides" blocks. */ -]b4_user_code([b4_percent_code_provides])])[] +b4_percent_code_get([[provides]])[]dnl ])dnl b4_defines_if m4_divert_pop(0)