X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/c3e9f08f93bc8bbabcd4f4093e52ad8f8b5454ca..1168b32295f6acde7a777d9519723fe276155b6b:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index 7f73c26d..3a679141 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -227,6 +227,8 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[ # b4_declare_yyparse_push_ # ------------------------ +# Declaration of yyparse (and dependencies) when using the push parser +# (including in pull mode). m4_define([b4_declare_yyparse_push_], [[typedef struct ]b4_prefix[pstate ]b4_prefix[pstate; enum { YYPUSH_MORE = 4 }; @@ -272,11 +274,14 @@ m4_define([b4_declare_yyparse], # Declaration that might either go into the header (if --defines) # or open coded in the parser body. m4_define([b4_shared_declarations], -[b4_percent_code_get([[requires]])[ +[b4_cpp_guard_open([b4_spec_defines_file])[ +]b4_declare_yydebug[ +]b4_percent_code_get([[requires]])[ ]b4_token_enums_defines(b4_tokens)[ ]b4_declare_yylstype[ ]b4_declare_yyparse[ -]b4_percent_code_get([[provides]])[]dnl +]b4_percent_code_get([[provides]])[ +]b4_cpp_guard_close([b4_spec_defines_file])[]dnl ]) ## -------------- ## @@ -302,7 +307,15 @@ b4_copyright([Bison implementation for Yacc-like parsers in C], ]b4_identification b4_percent_code_get([[top]])[]dnl -m4_if(b4_prefix, [yy], [], +m4_if(b4_api_prefix, [yy], [], +[[/* Substitute the type names. */ +#define YYSTYPE ]b4_api_PREFIX[STYPE +#define YYSTYPE_IS_TRIVIAL ]b4_api_PREFIX[STYPE_IS_TRIVIAL +#define YYSTYPE_IS_DECLARED ]b4_api_PREFIX[STYPE_IS_DECLARED]b4_locations_if([[ +#define YYLTYPE ]b4_api_PREFIX[LTYPE +#define YYLTYPE_IS_TRIVIAL ]b4_api_PREFIX[LTYPE_IS_TRIVIAL +#define YYLTYPE_IS_DECLARED ]b4_api_PREFIX[LTYPE_IS_DECLARED]])])[ +]m4_if(b4_prefix, [yy], [], [[/* Substitute the variable and function names. */]b4_pull_if([[ #define yyparse ]b4_prefix[parse]])b4_push_if([[ #define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[ @@ -315,19 +328,14 @@ m4_if(b4_prefix, [yy], [], #define yylval ]b4_prefix[lval #define yychar ]b4_prefix[char #define yydebug ]b4_prefix[debug -#define yynerrs ]b4_prefix[nerrs -]b4_locations_if([[#define yylloc ]b4_prefix[lloc]])])[ +#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[ +#define yylloc ]b4_prefix[lloc]])])[ /* Copy the first part of user declarations. */ ]b4_user_pre_prologue[ ]b4_null_define[ -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ -#endif - /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE @@ -336,13 +344,9 @@ m4_if(b4_prefix, [yy], [], # define YYERROR_VERBOSE ]b4_error_verbose_flag[ #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE ]b4_token_table[ -#endif - -]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], - [b4_shared_declarations])[ +/* In a future release of Bison, this section will be replaced + by #include "@basename(]b4_spec_defines_file[@)". */ +]b4_shared_declarations[ /* Copy the second part of user declarations. */ ]b4_user_post_prologue @@ -585,7 +589,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] = ]b4_translate[ }; -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = @@ -606,7 +610,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -799,7 +803,7 @@ while (YYID (0)) #endif /* Enable debugging if requested. */ -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ @@ -886,12 +890,12 @@ do { \ /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; -#else /* !YYDEBUG */ +#else /* !]b4_api_PREFIX[DEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ +#endif /* !]b4_api_PREFIX[DEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ @@ -922,7 +926,7 @@ int yydebug; required. Return 1 if memory is exhausted. */ static int yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG char const *yydebug_prefix, char const *yydebug_suffix, #endif @@ -1028,7 +1032,7 @@ do { \ the parser stacks to try to find a new initial context in which the current lookahead is syntactically acceptable. If it fails to find such a context, it discards the lookahead. */ -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG # define YY_LAC_DISCARD(Event) \ do { \ if (yy_lac_established) \ @@ -1131,7 +1135,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, else { if (yy_lac_stack_realloc (yyes_capacity, 1, -#if YYDEBUG +#if ]b4_api_PREFIX[DEBUG " (", ")", #endif yyes, yyesa, &yyesp, yyes_prev)) @@ -1338,7 +1342,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yysize = yysize1; } }]b4_lac_if([[ -# if YYDEBUG +# if ]b4_api_PREFIX[DEBUG else if (yydebug) YYFPRINTF (stderr, "No expected tokens.\n"); # endif]])[ @@ -2069,10 +2073,6 @@ b4_defines_if( b4_copyright([Bison interface for Yacc-like parsers in C], [1984, 1989-1990, 2000-2012])[ -]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_shared_declarations[ -]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval; -]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[ -]b4_cpp_guard_close([b4_spec_defines_file])[ ]])dnl b4_defines_if m4_divert_pop(0)