Index: ChangeLog from Akim Demaille Implement --trace=m4. * src/getargs.c (trace_types, trace_args): Accept trace_m4. * src/output.c (output_skeleton): When set, pass -dV to m4. Factor the handling of flags in m4. * src/output.c (prepare): Rename the muscle names debug, defines, error_verbose to debug_flag, defines_flag, error_verbose_flag. * data/c.m4: Adjust. (_b4_define_flag_if, b4_define_flag_if, b4_defines_if): New. Use b4_define_flag_if to define other b4_FLAG_if macros. (b4_location_if): As a consequence, rename as... (b4_locations_if): this, for consistency. Adjust all the skeletons. +2006-05-14 Akim Demaille + * etc/bench.pm: Shorten bench names. 2006-05-14 Akim Demaille Index: data/c.m4 =================================================================== RCS file: /cvsroot/bison/bison/data/c.m4,v retrieving revision 1.54 diff -u -r1.54 c.m4 --- data/c.m4 14 May 2006 07:00:18 -0000 1.54 +++ data/c.m4 14 May 2006 20:39:36 -0000 @@ -74,7 +74,7 @@ [#]define YYSKELETON_NAME b4_skeleton /* Pure parsers. */ -[#]define YYPURE b4_pure +[#]define YYPURE b4_pure_flag /* Using locations. */ [#]define YYLSP_NEEDED b4_locations_flag @@ -171,32 +171,42 @@ ## Decoding options. ## ## ------------------ ## - -# b4_error_verbose_if(IF-TRUE, IF-FALSE) -# -------------------------------------- -# Expand IF-TRUE, if errors are verbose, IF-FALSE otherwise. -m4_define([b4_error_verbose_if], -[m4_if(b4_error_verbose, [1], - [$1], - [$2])]) +# b4_flag_if(FLAG, IF-TRUE, IF-FALSE) +# ----------------------------------- +# Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail. +m4_define([b4_flag_if], +[m4_case(b4_$1_flag, + [0], [$3], + [1], [$2], + [m4_fatal([invalid $1 value: ]$1)])]) -# b4_location_if(IF-TRUE, IF-FALSE) -# --------------------------------- -# Expand IF-TRUE, if locations are used, IF-FALSE otherwise. -m4_define([b4_location_if], -[m4_if(b4_locations_flag, [1], - [$1], - [$2])]) +# b4_define_flag_if(FLAG) +# ----------------------- +# Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the +# value of the Boolean FLAG. +m4_define([b4_define_flag_if], +[_b4_define_flag_if($[1], $[2], [$1])]) + +# _b4_define_flag_if($1, $2, FLAG) +# -------------------------------- +# This macro works around the impossibility to define macros +# inside macros, because issuing `[$1]' is not possible in M4 :(. +# This sucks hard, GNU M4 should really provide M5 like $$1. +m4_define([_b4_define_flag_if], +[m4_if([$1$2], $[1]$[2], [], + [m4_fatal([$0: Invalid arguments: address@hidden)])dnl +m4_define([b4_$3_if], + [b4_flag_if([$3], [$1], [$2])])]) -# b4_pure_if(IF-TRUE, IF-FALSE) +# b4_FLAG_if(IF-TRUE, IF-FALSE) # ----------------------------- -# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise. -m4_define([b4_pure_if], -[m4_if(b4_pure, [1], - [$1], - [$2])]) +# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise. +b4_define_flag_if([defines]) # Whether headers are requested. +b4_define_flag_if([error_verbose]) # Wheter error are verbose. +b4_define_flag_if([locations]) # Whether locations are tracked. +b4_define_flag_if([pure]) # Whether the interface is pure. @@ -393,8 +403,7 @@ # b4_syncline(LINE, FILE) # ----------------------- m4_define([b4_syncline], -[m4_if(b4_synclines_flag, 1, - [[#]line $1 $2])]) +[b4_flag_if([synclines], [[#]line $1 $2])]) @@ -436,11 +445,11 @@ [[const char *yymsg], [yymsg]], [[int yytype], [yytype]], [[YYSTYPE *yyvaluep], [yyvaluep]][]dnl -b4_location_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl +b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl m4_ifset([b4_parse_param], [, b4_parse_param]))[ { YYUSE (yyvaluep); -]b4_location_if([ YYUSE (yylocationp); +]b4_locations_if([ YYUSE (yylocationp); ])dnl b4_parse_param_use[]dnl [ @@ -475,12 +484,12 @@ [[FILE *yyoutput], [yyoutput]], [[int yytype], [yytype]], [[const YYSTYPE * const yyvaluep], [yyvaluep]][]dnl -b4_location_if([, [[const YYLTYPE * const yylocationp], [yylocationp]]])[]dnl +b4_locations_if([, [[const YYLTYPE * const yylocationp], [yylocationp]]])[]dnl m4_ifset([b4_parse_param], [, b4_parse_param]))[ { if (!yyvaluep) return; -]b4_location_if([ YYUSE (yylocationp); +]b4_locations_if([ YYUSE (yylocationp); ])dnl b4_parse_param_use[]dnl [# ifdef YYPRINT @@ -507,7 +516,7 @@ [[FILE *yyoutput], [yyoutput]], [[int yytype], [yytype]], [[const YYSTYPE * const yyvaluep], [yyvaluep]][]dnl -b4_location_if([, [[const YYLTYPE * const yylocationp], [yylocationp]]])[]dnl +b4_locations_if([, [[const YYLTYPE * const yylocationp], [yylocationp]]])[]dnl m4_ifset([b4_parse_param], [, b4_parse_param]))[ { if (yytype < YYNTOKENS) @@ -515,11 +524,11 @@ else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); -]b4_location_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp); +]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp); YYFPRINTF (yyoutput, ": "); ])dnl [ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl -b4_location_if([, yylocationp])[]b4_user_args[); +b4_locations_if([, yylocationp])[]b4_user_args[); YYFPRINTF (yyoutput, ")"); }]dnl ]) Index: data/glr.c =================================================================== RCS file: /cvsroot/bison/bison/data/glr.c,v retrieving revision 1.172 diff -u -r1.172 glr.c --- data/glr.c 14 May 2006 07:00:18 -0000 1.172 +++ data/glr.c 14 May 2006 20:39:36 -0000 @@ -52,7 +52,7 @@ # Yes, this is quite ugly... m4_define([b4_lex_param], m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl -b4_location_if([, [[YYLTYPE *], [&yylloc]]])])dnl +b4_locations_if([, [[YYLTYPE *], [&yylloc]]])])dnl m4_ifdef([b4_lex_param], [, ]b4_lex_param))) @@ -61,7 +61,7 @@ # Optional effective arguments passed to yyerror: user args plus yylloc, and # a trailing comma. m4_define([b4_yyerror_args], -[b4_pure_if([b4_location_if([yylocp, ])])dnl +[b4_pure_if([b4_locations_if([yylocp, ])])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) @@ -69,7 +69,7 @@ # ---------------- # Same as above, but on the look-ahead, hence &yylloc instead of yylocp. m4_define([b4_lyyerror_args], -[b4_pure_if([b4_location_if([&yylloc, ])])dnl +[b4_pure_if([b4_locations_if([&yylloc, ])])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) @@ -77,21 +77,21 @@ # ------------ # Same as b4_yyerror_args, but with a leading comma. m4_define([b4_pure_args], -[b4_pure_if([b4_location_if([, yylocp])])[]b4_user_args]) +[b4_pure_if([b4_locations_if([, yylocp])])[]b4_user_args]) # b4_lpure_args # ------------- # Same as above, but on the look-ahead, hence &yylloc instead of yylocp. m4_define([b4_lpure_args], -[b4_pure_if([b4_location_if([, &yylloc])])[]b4_user_args]) +[b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args]) # b4_pure_formals # --------------- # Arguments passed to yyerror: user formals plus yylocp. m4_define([b4_pure_formals], -[b4_pure_if([b4_location_if([, YYLTYPE *yylocp])])[]b4_user_formals]) +[b4_pure_if([b4_locations_if([, YYLTYPE *yylocp])])[]b4_user_formals]) ## ----------------- ## @@ -186,7 +186,7 @@ #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { -]b4_location_if([ +]b4_locations_if([ int first_line; int first_column; int last_line; @@ -200,13 +200,12 @@ #endif ]]) -m4_if(b4_defines_flag, 0, - [b4_shared_declarations], - [#include @address@hidden)[ +b4_defines_if([#include @address@hidden, + [b4_shared_declarations])[ /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug[ +# define YYDEBUG ]b4_debug_flag[ #endif /* Enabling verbose error messages. */ @@ -214,7 +213,7 @@ # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE ]b4_error_verbose[ +# define YYERROR_VERBOSE ]b4_error_verbose_flag[ #endif /* Enabling the token table. */ @@ -308,7 +307,7 @@ # endif #endif -]b4_location_if([#define YYOPTIONAL_LOC(Name) Name],[ +]b4_locations_if([#define YYOPTIONAL_LOC(Name) Name],[ #ifdef __cplusplus # define YYOPTIONAL_LOC(Name) /* empty */ #else @@ -486,7 +485,7 @@ If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ -]b4_location_if([[ +]b4_locations_if([[ #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ @@ -581,7 +580,7 @@ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, Type, \ - Value]b4_location_if([, Location])[]b4_user_args[); \ + Value]b4_locations_if([, Location])[]b4_user_args[); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) @@ -622,7 +621,7 @@ #ifndef YYSTACKEXPANDABLE # if (! defined __cplusplus \ - || (]b4_location_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)) # define YYSTACKEXPANDABLE 1 # else @@ -794,7 +793,7 @@ struct yyGLRStack { int yyerrState; -]b4_location_if([[ /* To compute the location of the error token. */ +]b4_locations_if([[ /* To compute the location of the error token. */ yyGLRStackItem yyerror_range[3];]])[ ]b4_pure_if( [ @@ -923,7 +922,7 @@ else *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval; YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen); -]b4_location_if([[ yystackp->yyerror_range[1].yystate.yyloc = *yylocp; +]b4_locations_if([[ yystackp->yyerror_range[1].yystate.yyloc = *yylocp; ]])[ switch (yyn) { @@ -973,7 +972,7 @@ { if (yys->yyresolved) yydestruct (yymsg, yystos[yys->yylrState], - &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[]b4_user_args[); + &yys->yysemantics.yysval]b4_locations_if([, &yys->yyloc])[]b4_user_args[); else { #if YYDEBUG @@ -984,7 +983,7 @@ else YYFPRINTF (stderr, "%s incomplete ", yymsg); yy_symbol_print (stderr, yystos[yys->yylrState], - NULL]b4_location_if([, &yys->yyloc])[]b4_user_args[); + NULL]b4_locations_if([, &yys->yyloc])[]b4_user_args[); YYFPRINTF (stderr, "\n"); } #endif @@ -1392,7 +1391,7 @@ yyGLRState* yys; yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1]; yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred - = yystackp->yytops.yystates[yyk];]b4_location_if([[ + = yystackp->yytops.yystates[yyk];]b4_locations_if([[ if (yynrhs == 0) /* Set default location. */ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[ @@ -1443,7 +1442,7 @@ fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &]b4_rhs_value(yynrhs, yyi + 1)[ - ]b4_location_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl + ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl b4_user_args[); fprintf (stderr, "\n"); } @@ -1716,7 +1715,7 @@ return yyflag; } - yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_location_if([[ + yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_locations_if([[ if (yynrhs == 0) /* Set default location. */ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[ @@ -1929,7 +1928,7 @@ { yydestruct ("Cleanup: discarding incompletely merged value for", yystos[yys->yylrState], - &yysval]b4_location_if([, yylocp])[]b4_user_args[); + &yysval]b4_locations_if([, yylocp])[]b4_user_args[); break; } yyuserMerge (yymerger[yyp->yyrule], &yysval, &yysval_other); @@ -2189,7 +2188,7 @@ if (yychar == YYEOF) yyFail (yystackp][]b4_lpure_args[, NULL); if (yychar != YYEMPTY) - {]b4_location_if([[ + {]b4_locations_if([[ /* We throw away the lookahead, but the error range of the shifted error token must take it into account. */ yyGLRState *yys = yystackp->yytops.yystates[0]; @@ -2199,7 +2198,7 @@ YYLLOC_DEFAULT ((yys->yyloc), yyerror_range, 2);]])[ yytoken = YYTRANSLATE (yychar); yydestruct ("Error: discarding", - yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[); + yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); } YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; @@ -2242,7 +2241,7 @@ && yyisShiftAction (yytable[yyj])) { /* Shift the error token having adjusted its location. */ - YYLTYPE yyerrloc;]b4_location_if([[ + YYLTYPE yyerrloc;]b4_locations_if([[ yystackp->yyerror_range[2].yystate.yyloc = yylloc; YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[ YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]], @@ -2253,7 +2252,7 @@ break; } } -]b4_location_if([[ yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[ +]b4_locations_if([[ yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[ yydestroyGLRState ("Error: popping", yys]b4_user_args[); yystackp->yytops.yystates[0] = yys->yypred; yystackp->yynextFree -= 1; @@ -2295,7 +2294,7 @@ yychar = YYEMPTY; yylval = yyval_default; -]b4_location_if([ +]b4_locations_if([ #if YYLTYPE_IS_TRIVIAL yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 0; @@ -2344,7 +2343,7 @@ yyrule = yydefaultAction (yystate); if (yyrule == 0) { -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ +]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } @@ -2377,7 +2376,7 @@ } else if (yyisErrorAction (yyaction)) { -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ +]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } @@ -2423,7 +2422,7 @@ yyFail (&yystack][]b4_lpure_args[, YY_("syntax error")); YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ +]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ yyreportSyntaxError (&yystack]b4_user_args[); goto yyuser_error; } @@ -2488,7 +2487,7 @@ if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", YYTRANSLATE (yychar), - &yylval]b4_location_if([, &yylloc])[]b4_user_args[); + &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); /* If the stack is well-formed, pop the stack until it is empty, destroying its entries as we go. But free the stack regardless @@ -2506,7 +2505,7 @@ while (yystates[yyk]) { yyGLRState *yys = yystates[yyk]; -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]] +]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]] )[ yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[); yystates[yyk] = yys->yypred; yystack.yynextFree -= 1; @@ -2595,7 +2594,7 @@ ] b4_epilogue -m4_if(b4_defines_flag, 0, [], +b4_defines_if( address@hidden @output_header_name@ b4_copyright([Skeleton interface for Bison GLR parsers in C], [2002, 2003, 2004, 2005, 2006]) @@ -2604,7 +2603,7 @@ extern YYSTYPE b4_prefix[]lval; -b4_location_if([b4_pure_if([], +b4_locations_if([b4_pure_if([], [extern YYLTYPE b4_prefix[]lloc;]) ]) ]) Index: data/glr.cc =================================================================== RCS file: /cvsroot/bison/bison/data/glr.cc,v retrieving revision 1.17 diff -u -r1.17 glr.cc --- data/glr.cc 14 May 2006 07:00:18 -0000 1.17 +++ data/glr.cc 14 May 2006 20:39:37 -0000 @@ -49,7 +49,7 @@ # We require a pure interface using locations. m4_define([b4_location_flag], [1]) -m4_define([b4_pure], [1]) +m4_define([b4_pure_flag], [1]) m4_include(b4_pkgdatadir/[c++.m4]) m4_include(b4_pkgdatadir/[location.cc]) @@ -80,7 +80,7 @@ b4_parse_param)[ { ]b4_parse_param_use[]dnl -[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_location_if([, yylocationp])[); +[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([, yylocationp])[); } ]]) @@ -243,7 +243,7 @@ /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug[ +# define YYDEBUG ]b4_debug_flag[ #endif /* Enabling verbose error messages. */ @@ -251,7 +251,7 @@ # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE ]b4_error_verbose[ +# define YYERROR_VERBOSE ]b4_error_verbose_flag[ #endif /* Enabling the token table. */ Index: data/lalr1.cc =================================================================== RCS file: /cvsroot/bison/bison/data/lalr1.cc,v retrieving revision 1.128 diff -u -r1.128 lalr1.cc --- data/lalr1.cc 14 May 2006 07:00:18 -0000 1.128 +++ data/lalr1.cc 14 May 2006 20:39:37 -0000 @@ -27,7 +27,7 @@ # We do want M4 expansion after # for CPP macros. m4_changecom() m4_divert(0)dnl -m4_if(b4_defines_flag, 0, [], +b4_defines_if( address@hidden @output_header_name@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], [2002, 2003, 2004, 2005, 2006]) @@ -59,7 +59,7 @@ /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug[ +# define YYDEBUG ]b4_debug_flag[ #endif /* Enabling verbose error messages. */ @@ -67,7 +67,7 @@ # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE ]b4_error_verbose[ +# define YYERROR_VERBOSE ]b4_error_verbose_flag[ #endif /* Enabling the token table. */ @@ -303,8 +303,7 @@ [ // Take the name prefix into account. #define yylex b4_prefix[]lex]) -m4_if(b4_defines_flag, 0, [], -[ +b4_defines_if([ #include @address@hidden)[ /* User implementation prologue. */ @@ -580,7 +579,7 @@ YYCDEBUG << "Reading a token: "; yychar = ]b4_c_function_call([yylex], [int], [[YYSTYPE*], [&yylval]][]dnl -b4_location_if([, [[location*], [&yylloc]]])dnl +b4_locations_if([, [[location*], [&yylloc]]])dnl m4_ifdef([b4_lex_param], [, ]b4_lex_param))[; } Index: data/yacc.c =================================================================== RCS file: /cvsroot/bison/bison/data/yacc.c,v retrieving revision 1.137 diff -u -r1.137 yacc.c --- data/yacc.c 14 May 2006 07:00:18 -0000 1.137 +++ data/yacc.c 14 May 2006 20:39:37 -0000 @@ -49,7 +49,7 @@ # --------------- # Arguments passed to yyerror: user args plus yylloc. m4_define([b4_yyerror_args], -[b4_yacc_pure_if([b4_location_if([&yylloc, ])])dnl +[b4_yacc_pure_if([b4_locations_if([&yylloc, ])])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) @@ -59,7 +59,7 @@ # b4_lex_param arrives quoted twice, but we want to keep only one level. m4_define([b4_lex_param], m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl -b4_location_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnl +b4_locations_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnl m4_ifdef([b4_lex_param], b4_lex_param))) @@ -135,7 +135,7 @@ m4_changecom() m4_divert(0)dnl @output @output_parser_name@ -b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C], +b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl ' [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])[ /* C LALR(1) parser skeleton written by Richard Stallman, by @@ -158,7 +158,7 @@ #define yychar b4_prefix[]char #define yydebug b4_prefix[]debug #define yynerrs b4_prefix[]nerrs -b4_location_if([#define yylloc b4_prefix[]lloc])])[ +b4_locations_if([#define yylloc b4_prefix[]lloc])])[ ]b4_token_enums_defines(b4_tokens)[ @@ -167,7 +167,7 @@ /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug[ +# define YYDEBUG ]b4_debug_flag[ #endif /* Enabling verbose error messages. */ @@ -175,7 +175,7 @@ # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE ]b4_error_verbose[ +# define YYERROR_VERBOSE ]b4_error_verbose_flag[ #endif /* Enabling the token table. */ @@ -196,7 +196,7 @@ # define YYSTYPE_IS_TRIVIAL 1 #endif -]b4_location_if([#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +]b4_locations_if([#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int first_line; @@ -359,7 +359,7 @@ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (]b4_location_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ @@ -367,7 +367,7 @@ { yytype_int16 yyss; YYSTYPE yyvs; - ]b4_location_if([ YYLTYPE yyls; + ]b4_locations_if([ YYLTYPE yyls; ])dnl [}; @@ -376,7 +376,7 @@ /* The size of an array large to enough to hold all stacks, each with N elements. */ -]b4_location_if( +]b4_locations_if( [# define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM)], @@ -633,7 +633,7 @@ /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM -# define YYLEX yylex (]b4_pure_if([&yylval[]b4_location_if([, &yylloc]), ])[YYLEX_PARAM) +# define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM) #else # define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[ #endif @@ -658,7 +658,7 @@ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value]b4_location_if([, Location])[]b4_user_args[); \ + Type, Value]b4_locations_if([, Location])[]b4_user_args[); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) @@ -693,7 +693,7 @@ ]b4_c_function_def([yy_reduce_print], [static void], [[YYSTYPE *yyvsp], [yyvsp]], - b4_location_if([[[YYLTYPE *yylsp], [yylsp]],]) + b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],]) [[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,]) b4_parse_param)[ { @@ -708,7 +708,7 @@ fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &]b4_rhs_value(yynrhs, yyi + 1)[ - ]b4_location_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl + ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl b4_user_args[); fprintf (stderr, "\n"); } @@ -717,7 +717,7 @@ # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyvsp, ]b4_location_if([yylsp, ])[Rule]b4_user_args[); \ + yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that @@ -971,7 +971,7 @@ YYSTYPE yylval; /* Number of syntax errors so far. */ -int yynerrs;b4_location_if([ +int yynerrs;b4_locations_if([ /* Location data for the look-ahead symbol. */ YYLTYPE yylloc;]) ]) @@ -1024,7 +1024,7 @@ YYSTYPE *yyvs = yyvsa; YYSTYPE *yyvsp; -]b4_location_if( +]b4_locations_if( [[ /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; @@ -1032,14 +1032,14 @@ /* The locations where the error started and ended. */ YYLTYPE yyerror_range[2];]])[ -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_location_if([, yylsp -= (N)])[) +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -]b4_location_if([ YYLTYPE yyloc;])[ +]b4_locations_if([ YYLTYPE yyloc;])[ /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ @@ -1059,7 +1059,7 @@ yyssp = yyss; yyvsp = yyvs; -]b4_location_if([[ yylsp = yyls; +]b4_locations_if([[ yylsp = yyls; #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; @@ -1105,7 +1105,7 @@ memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; -]b4_location_if([ YYLTYPE *yyls1 = yyls;])[ +]b4_locations_if([ YYLTYPE *yyls1 = yyls;])[ /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a @@ -1114,9 +1114,9 @@ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), -]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[ +]b4_locations_if([ &yyls1, yysize * sizeof (*yylsp),])[ &yystacksize); -]b4_location_if([ yyls = yyls1;])[ +]b4_locations_if([ yyls = yyls1;])[ yyss = yyss1; yyvs = yyvs1; } @@ -1139,7 +1139,7 @@ goto yyexhaustedlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); -]b4_location_if([ YYSTACK_RELOCATE (yyls);])[ +]b4_locations_if([ YYSTACK_RELOCATE (yyls);])[ # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1149,7 +1149,7 @@ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; -]b4_location_if([ yylsp = yyls + yysize - 1;])[ +]b4_locations_if([ yylsp = yyls + yysize - 1;])[ YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1226,7 +1226,7 @@ yystate = yyn; *++yyvsp = yylval; -]b4_location_if([ *++yylsp = yylloc;])[ +]b4_locations_if([ *++yylsp = yylloc;])[ goto yynewstate; @@ -1257,7 +1257,7 @@ GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; -]b4_location_if( +]b4_locations_if( [[ /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[ YY_REDUCE_PRINT (yyn); @@ -1275,7 +1275,7 @@ YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; -]b4_location_if([ *++yylsp = yyloc;])[ +]b4_locations_if([ *++yylsp = yyloc;])[ /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule @@ -1337,7 +1337,7 @@ #endif } -]b4_location_if([[ yyerror_range[0] = yylloc;]])[ +]b4_locations_if([[ yyerror_range[0] = yylloc;]])[ if (yyerrstatus == 3) { @@ -1353,7 +1353,7 @@ else { yydestruct ("Error: discarding", - yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[); + yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); yychar = YYEMPTY; } } @@ -1374,7 +1374,7 @@ if (/*CONSTCOND*/ 0) goto yyerrorlab; -]b4_location_if([[ yyerror_range[0] = yylsp[1-yylen]; +]b4_locations_if([[ yyerror_range[0] = yylsp[1-yylen]; ]])[ /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -1408,9 +1408,9 @@ if (yyssp == yyss) YYABORT; -]b4_location_if([[ yyerror_range[0] = *yylsp;]])[ +]b4_locations_if([[ yyerror_range[0] = *yylsp;]])[ yydestruct ("Error: popping", - yystos[yystate], yyvsp]b4_location_if([, yylsp])[]b4_user_args[); + yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1420,7 +1420,7 @@ YYACCEPT; *++yyvsp = yylval; -]b4_location_if([[ +]b4_locations_if([[ yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of the look-ahead. YYLOC is available though. */ @@ -1461,7 +1461,7 @@ yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[); + yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -1469,7 +1469,7 @@ while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[]b4_user_args[); + yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1485,9 +1485,9 @@ b4_epilogue -m4_if(b4_defines_flag, 0, [], +b4_defines_if( address@hidden @output_header_name@ -b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C], +b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) b4_token_enums_defines(b4_tokens) @@ -1508,7 +1508,7 @@ b4_pure_if([], [extern YYSTYPE b4_prefix[]lval;]) -b4_location_if( +b4_locations_if( [#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { @@ -1522,7 +1522,7 @@ # define YYLTYPE_IS_TRIVIAL 1 #endif -m4_if(b4_pure, [0], -[extern YYLTYPE b4_prefix[]lloc;]) -]) -]) +b4_pure_if([], + [extern YYLTYPE b4_prefix[]lloc;]) +])dnl b4_locations_if +])dnl b4_defines_if Index: src/getargs.c =================================================================== RCS file: /cvsroot/bison/bison/src/getargs.c,v retrieving revision 1.67 diff -u -r1.67 getargs.c --- src/getargs.c 14 May 2006 19:14:10 -0000 1.67 +++ src/getargs.c 14 May 2006 20:39:37 -0000 @@ -84,7 +84,8 @@ "grammar - reading, reducing of the grammar", "resource - memory consumption (where available)", "sets - grammar sets: firsts, nullable etc.", - "tools - m4 invocation and preserve the temporary file", + "tools - m4 invocation", + "m4 - m4 traces", "skeleton - skeleton postprocessing", "time - time consumption", "all - all of the above", @@ -102,6 +103,7 @@ trace_resource, trace_sets, trace_tools, + trace_m4, trace_skeleton, trace_time, trace_all Index: src/getargs.h =================================================================== RCS file: /cvsroot/bison/bison/src/getargs.h,v retrieving revision 1.29 diff -u -r1.29 getargs.h --- src/getargs.h 14 May 2006 19:14:10 -0000 1.29 +++ src/getargs.h 14 May 2006 20:39:37 -0000 @@ -73,6 +73,7 @@ trace_grammar = 1 << 7, trace_time = 1 << 8, trace_skeleton = 1 << 9, + trace_m4 = 1 << 10, trace_all = ~0 }; extern int trace_flag; Index: src/output.c =================================================================== RCS file: /cvsroot/bison/bison/src/output.c,v retrieving revision 1.246 diff -u -r1.246 output.c --- src/output.c 14 May 2006 19:14:10 -0000 1.246 +++ src/output.c 14 May 2006 20:39:38 -0000 @@ -501,7 +501,7 @@ FILE *in; FILE *out; int filter_fd[2]; - char const *argv[5]; + char const *argv[6]; pid_t pid; /* Compute the names of the package data dir and skeleton file. @@ -538,7 +538,8 @@ argv[1] = full_m4sugar; argv[2] = "-"; argv[3] = full_skeleton; - argv[4] = NULL; + argv[4] = trace_flag & trace_m4 ? "-dV" : NULL; + argv[5] = NULL; init_subpipe (); pid = create_subpipe (argv, filter_fd); @@ -582,11 +583,11 @@ prepare (void) { /* Flags. */ - MUSCLE_INSERT_BOOL ("debug", debug_flag); + MUSCLE_INSERT_BOOL ("debug_flag", debug_flag); MUSCLE_INSERT_BOOL ("defines_flag", defines_flag); - MUSCLE_INSERT_BOOL ("error_verbose", error_verbose); + MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose); MUSCLE_INSERT_BOOL ("locations_flag", locations_flag); - MUSCLE_INSERT_BOOL ("pure", pure_parser); + MUSCLE_INSERT_BOOL ("pure_flag", pure_parser); MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag); /* File names. */