mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 04:43:03 +00:00
* data/lalr1.cc, data/yacc.c, data/glr.c, data/c.m4
(b4_yysymprint_generate): Rename as... (b4_yy_symbol_print_generate): this. Generate yy_symbol_print instead of yysymprint. Generate also yy_symbol_value_print, and use it.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2005-12-22 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* data/lalr1.cc, data/yacc.c, data/glr.c, data/c.m4
|
||||
(b4_yysymprint_generate): Rename as...
|
||||
(b4_yy_symbol_print_generate): this.
|
||||
Generate yy_symbol_print instead of yysymprint.
|
||||
Generate also yy_symbol_value_print, and use it.
|
||||
|
||||
2005-12-22 Akim Demaille <akim@epita.fr>
|
||||
|
||||
Warn about unused values.
|
||||
|
||||
49
data/c.m4
49
data/c.m4
@@ -429,18 +429,19 @@ b4_parse_param_use[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_yysymprint_generate(FUNCTION-DECLARATOR)
|
||||
# -------------------------------------------
|
||||
# Generate the "yysymprint" function, which declaration is issued using
|
||||
# b4_yy_symbol_print_generate(FUNCTION-DECLARATOR)
|
||||
# ------------------------------------------------
|
||||
# Generate the "yy_symbol_print" function, which declaration is issued using
|
||||
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||
# or "b4_c_function_def" for K&R.
|
||||
m4_define_default([b4_yysymprint_generate],
|
||||
[[/*--------------------------------.
|
||||
m4_define_default([b4_yy_symbol_print_generate],
|
||||
[[
|
||||
/*--------------------------------.
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
]$1([yysymprint],
|
||||
]$1([yy_symbol_value_print],
|
||||
[static void],
|
||||
[[FILE *yyoutput], [yyoutput]],
|
||||
[[int yytype], [yytype]],
|
||||
@@ -452,16 +453,7 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
]b4_location_if([ YYUSE (yylocationp);
|
||||
])dnl
|
||||
b4_parse_param_use[]dnl
|
||||
[ if (yytype < YYNTOKENS)
|
||||
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
|
||||
else
|
||||
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
||||
|
||||
]b4_location_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
||||
YYFPRINTF (yyoutput, ": ");
|
||||
])dnl
|
||||
[
|
||||
# ifdef YYPRINT
|
||||
[# ifdef YYPRINT
|
||||
if (yytype < YYNTOKENS)
|
||||
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
|
||||
# endif
|
||||
@@ -471,6 +463,31 @@ b4_parse_param_use[]dnl
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------.
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
]$1([yy_symbol_print],
|
||||
[static void],
|
||||
[[FILE *yyoutput], [yyoutput]],
|
||||
[[int yytype], [yytype]],
|
||||
[[const YYSTYPE * const yyvaluep], [yyvaluep]][]dnl
|
||||
b4_location_if([, [[const YYLTYPE * const yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
{
|
||||
if (yytype < YYNTOKENS)
|
||||
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
|
||||
else
|
||||
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
||||
|
||||
]b4_location_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
||||
YYFPRINTF (yyoutput, ": ");
|
||||
])dnl
|
||||
[ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl
|
||||
b4_location_if([, yylocationp])[]b4_user_args[);
|
||||
YYFPRINTF (yyoutput, ")");
|
||||
}]dnl
|
||||
])
|
||||
|
||||
14
data/glr.c
14
data/glr.c
@@ -577,14 +577,14 @@ do { \
|
||||
YYFPRINTF Args; \
|
||||
} while (YYID (0))
|
||||
|
||||
]b4_yysymprint_generate([b4_c_ansi_function_def])[
|
||||
]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
|
||||
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
{ \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yysymprint (stderr, \
|
||||
yy_symbol_print (stderr, \
|
||||
Type, Value]b4_location_if([, Location])[]b4_user_args[); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
@@ -976,7 +976,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
|
||||
if (yydebug)
|
||||
{
|
||||
YYFPRINTF (stderr, "%s unresolved ", yymsg);
|
||||
yysymprint (stderr, yystos[yys->yylrState],
|
||||
yy_symbol_print (stderr, yystos[yys->yylrState],
|
||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[]b4_user_args[);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
@@ -1407,10 +1407,10 @@ yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
for (yyi = 0; yyi < yynrhs; yyi++)
|
||||
{
|
||||
fprintf (stderr, " $%d = ", yyi + 1);
|
||||
yysymprint (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
||||
&]b4_rhs_value(yynrhs, yyi + 1)[
|
||||
]b4_location_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||
b4_user_args[);
|
||||
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_user_args[);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,13 +153,20 @@ b4_syncline([@oline@], [@ofile@])],
|
||||
b4_error_verbose_if([, int tok])[);
|
||||
|
||||
#if YYDEBUG
|
||||
/// \brief Report a symbol value on the debug stream.
|
||||
/// \param yytype The token type.
|
||||
/// \param yyvaluep Its semantic value.
|
||||
/// \param yylocationp Its location.
|
||||
virtual void yy_symbol_value_print_ (int yytype,
|
||||
const semantic_type* yyvaluep,
|
||||
const location_type* yylocationp);
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yytype The token type.
|
||||
/// \param yyvaluep Its semantic value.
|
||||
/// \param yylocationp Its location.
|
||||
virtual void yysymprint_ (int yytype,
|
||||
const semantic_type* yyvaluep,
|
||||
const location_type* yylocationp);
|
||||
virtual void yy_symbol_print_ (int yytype,
|
||||
const semantic_type* yyvaluep,
|
||||
const location_type* yylocationp);
|
||||
#endif /* ! YYDEBUG */
|
||||
|
||||
|
||||
@@ -331,7 +338,7 @@ do { \
|
||||
if (yydebug_) \
|
||||
{ \
|
||||
*yycdebug_ << Title << ' '; \
|
||||
yysymprint_ ((Type), (Value), (Location)); \
|
||||
yy_symbol_print_ ((Type), (Value), (Location)); \
|
||||
*yycdebug_ << std::endl; \
|
||||
} \
|
||||
} while (false)
|
||||
@@ -419,26 +426,29 @@ namespace yy
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
void
|
||||
]b4_parser_class_name[::yysymprint_ (int yytype,
|
||||
inline void
|
||||
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
|
||||
const semantic_type* yyvaluep, const location_type* yylocationp)
|
||||
{
|
||||
/* Backward compatibility, but should be removed eventually. */
|
||||
std::ostream& cdebug_ = *yycdebug_;
|
||||
|
||||
YYUSE (!&cdebug_);
|
||||
YYUSE (yylocationp);
|
||||
YYUSE (yyvaluep);
|
||||
|
||||
*yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
|
||||
<< ' ' << yytname_[yytype] << " ("
|
||||
<< *yylocationp << ": ";
|
||||
switch (yytype)
|
||||
{
|
||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
]b4_parser_class_name[::yy_symbol_print_ (int yytype,
|
||||
const semantic_type* yyvaluep, const location_type* yylocationp)
|
||||
{
|
||||
*yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
|
||||
<< ' ' << yytname_[yytype] << " ("
|
||||
<< *yylocationp << ": ";
|
||||
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
|
||||
*yycdebug_ << ')';
|
||||
}
|
||||
#endif /* ! YYDEBUG */
|
||||
|
||||
12
data/yacc.c
12
data/yacc.c
@@ -647,13 +647,13 @@ do { \
|
||||
if (yydebug) \
|
||||
{ \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yysymprint (stderr, \
|
||||
yy_symbol_print (stderr, \
|
||||
Type, Value]b4_location_if([, Location])[]b4_user_args[); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
} while (YYID (0))
|
||||
|
||||
]b4_yysymprint_generate([b4_c_function_def])[
|
||||
]b4_yy_symbol_print_generate([b4_c_function_def])[
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
|
||||
@@ -696,10 +696,10 @@ do { \
|
||||
for (yyi = 0; yyi < yynrhs; yyi++)
|
||||
{
|
||||
fprintf (stderr, " $%d = ", yyi + 1);
|
||||
yysymprint (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
||||
&]b4_rhs_value(yynrhs, yyi + 1)[
|
||||
]b4_location_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||
b4_user_args[);
|
||||
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_user_args[);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user