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.
This commit is contained in:
Akim Demaille
2006-05-14 20:40:35 +00:00
parent ba9ecd1910
commit 327afc7c84
9 changed files with 153 additions and 126 deletions

View File

@@ -74,7 +74,7 @@ m4_define([b4_identification],
[#]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 @@ m4_define([b4_int_type_for],
## 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: $@])])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 @@ m4_define([b4_c_arg],
# 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 @@ m4_define_default([b4_yydestruct_generate],
[[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 @@ m4_define_default([b4_yy_symbol_print_generate],
[[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 @@ b4_parse_param_use[]dnl
[[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 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
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
])

View File

@@ -52,7 +52,7 @@ m4_define([b4_user_formals],
# 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 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
# 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 @@ m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
# ----------------
# 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 @@ m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
# ------------
# 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 @@ b4_syncline([@oline@], [@ofile@])
#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 @@ typedef struct YYLTYPE
#endif
]])
m4_if(b4_defines_flag, 0,
[b4_shared_declarations],
[#include @output_header_name@])[
b4_defines_if([#include @output_header_name@],
[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 @@ m4_if(b4_defines_flag, 0,
# 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 @@ b4_syncline([@oline@], [@ofile@])
# 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 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
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 @@ do { \
{ \
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 @@ int yydebug;
#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 @@ union yyGLRStackItem {
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 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
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 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
{
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 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
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 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
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 @@ yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
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 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
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 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
{
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 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
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 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
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 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
&& 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 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
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 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
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 @@ b4_syncline([@oline@], [@ofile@])])dnl
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 @@ b4_syncline([@oline@], [@ofile@])])dnl
}
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 @@ b4_syncline([@oline@], [@ofile@])])dnl
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 @@ b4_syncline([@oline@], [@ofile@])])dnl
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 @@ b4_syncline([@oline@], [@ofile@])])dnl
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 @@ yypdumpstack (yyGLRStack* yystackp)
]
b4_epilogue
m4_if(b4_defines_flag, 0, [],
b4_defines_if(
[@output @output_header_name@
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002, 2003, 2004, 2005, 2006])
@@ -2604,7 +2603,7 @@ b4_shared_declarations
extern YYSTYPE b4_prefix[]lval;
b4_location_if([b4_pure_if([],
b4_locations_if([b4_pure_if([],
[extern YYLTYPE b4_prefix[]lloc;])
])
])

View File

@@ -49,7 +49,7 @@ m4_divert(-1) -*- C -*-
# 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 @@ m4_define([b4_yy_symbol_print_generate],
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 @@ b4_syncline([@oline@], [@ofile@])[
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG ]b4_debug[
# define YYDEBUG ]b4_debug_flag[
#endif
/* Enabling verbose error messages. */
@@ -251,7 +251,7 @@ b4_syncline([@oline@], [@ofile@])[
# 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. */

View File

@@ -27,7 +27,7 @@ m4_include(b4_pkgdatadir/[location.cc])
# We do want M4 expansion after # for CPP macros.
m4_changecom()
m4_divert(0)dnl
m4_if(b4_defines_flag, 0, [],
b4_defines_if(
[@output @output_header_name@
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
[2002, 2003, 2004, 2005, 2006])
@@ -59,7 +59,7 @@ b4_syncline([@oline@], [@ofile@])[
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG ]b4_debug[
# define YYDEBUG ]b4_debug_flag[
#endif
/* Enabling verbose error messages. */
@@ -67,7 +67,7 @@ b4_syncline([@oline@], [@ofile@])[
# 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 @@ m4_if(b4_prefix, [yy], [],
[
// Take the name prefix into account.
#define yylex b4_prefix[]lex])
m4_if(b4_defines_flag, 0, [],
[
b4_defines_if([
#include @output_header_name@])[
/* User implementation prologue. */
@@ -580,7 +579,7 @@ b4_syncline([@oline@], [@ofile@])])dnl
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))[;
}

View File

@@ -49,7 +49,7 @@ m4_define([b4_yacc_pure_if],
# ---------------
# 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 @@ m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
# 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_define([b4_rhs_location],
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 @@ m4_if(b4_prefix, [yy], [],
#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 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG ]b4_debug[
# define YYDEBUG ]b4_debug_flag[
#endif
/* Enabling verbose error messages. */
@@ -175,7 +175,7 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[
# 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 @@ b4_syncline([@oline@], [@ofile@])
# 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 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#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 @@ union yyalloc
{
yytype_int16 yyss;
YYSTYPE yyvs;
]b4_location_if([ YYLTYPE yyls;
]b4_locations_if([ YYLTYPE yyls;
])dnl
[};
@@ -376,7 +376,7 @@ union yyalloc
/* 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 @@ while (YYID (0))
/* 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 @@ do { \
{ \
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 @@ do { \
]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 @@ do { \
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 @@ do { \
# 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 @@ int yychar;
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 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
YYSTYPE *yyvs = yyvsa;
YYSTYPE *yyvsp;
]b4_location_if(
]b4_locations_if(
[[ /* The location stack. */
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls = yylsa;
@@ -1032,14 +1032,14 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
/* 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 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
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 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
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 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
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 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
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 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
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 @@ yybackup:
yystate = yyn;
*++yyvsp = yylval;
]b4_location_if([ *++yylsp = yylloc;])[
]b4_locations_if([ *++yylsp = yylloc;])[
goto yynewstate;
@@ -1257,7 +1257,7 @@ yyreduce:
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 @@ b4_syncline([@oline@], [@ofile@])[
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 @@ yyerrlab:
#endif
}
]b4_location_if([[ yyerror_range[0] = yylloc;]])[
]b4_locations_if([[ yyerror_range[0] = yylloc;]])[
if (yyerrstatus == 3)
{
@@ -1353,7 +1353,7 @@ yyerrlab:
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 @@ yyerrorlab:
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 @@ yyerrlab1:
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 @@ yyerrlab1:
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 @@ yyexhaustedlab:
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 @@ yyreturn:
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 @@ yyreturn:
b4_epilogue
m4_if(b4_defines_flag, 0, [],
b4_defines_if(
[@output @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_syncline([@oline@], [@ofile@])
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 @@ typedef struct YYLTYPE
# 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