* data/c.m4 (b4_parse_param_for, b4_parse_param_use): New.
* data/glr.c, data/glr.cc: Use them.
* data/glr.c (YYUSE): Have a C++ definition that supports
non-pointer types.
+2005-11-14 Akim Demaille <akim@epita.fr>
+
+ "Use" parse parameters.
+ * data/c.m4 (b4_parse_param_for, b4_parse_param_use): New.
+ * data/glr.c, data/glr.cc: Use them.
+ * data/glr.c (YYUSE): Have a C++ definition that supports
+ non-pointer types.
+
2005-11-14 Akim Demaille <akim@epita.fr>
* data/glr.c (yyexpandGLRStack): Declare only if defined.
m4_define([b4_parse_param],
b4_parse_param))
+# b4_parse_param_for(DECL, FORMAL, BODY)
+# ---------------------------------------
+# Iterate over the user parameters, binding the declaration to DECL,
+# the formal name to FORMAL, and evaluating the BODY.
+m4_define([b4_parse_param_for],
+[m4_foreach([$1_$2], m4_defn([b4_parse_param]),
+[m4_pushdef([$1], m4_fst($1_$2))dnl
+m4_pushdef([$2], m4_shift($1_$2))dnl
+$3[]dnl
+m4_popdef([$2])dnl
+m4_popdef([$1])dnl
+])])
+
+# b4_parse_param_use
+# ------------------
+# `YYUSE' all the parse-params.
+# WARNING: Ends with a dnl, there must be nothing behind it.
+m4_define([b4_parse_param_use],
+[b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
+])dnl
+])
## ------------ ##
## Data Types. ##
[[#]line $1 $2])])
+
+## -------------- ##
+## User actions. ##
+## -------------- ##
+
# b4_symbol_actions(FILENAME, LINENO,
# SYMBOL-TAG, SYMBOL-NUM,
# SYMBOL-ACTION, SYMBOL-TYPENAME)
{
YYUSE (yyvaluep);
]b4_location_if([ YYUSE (yylocationp);
-])[
+])dnl
+b4_parse_param_use[]dnl
+[
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
YYUSE (yyvaluep);
]b4_location_if([ YYUSE (yylocationp);
])dnl
-[
- if (yytype < YYNTOKENS)
+b4_parse_param_use[]dnl
+[ if (yytype < YYNTOKENS)
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
else
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
#endif
/* Suppress unused-variable warnings by "using" E. */
-#define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
+#if __cplusplus
+# define YYUSE(e) (void) (e)
+#else
+# define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
+#endif
#ifndef YYFREE
# define YYFREE free
yybool yynormal __attribute__ ((__unused__)) =
(yystack->yysplitPoint == NULL);
int yylow;
-
-# undef yyerrok
+]b4_parse_param_use[]dnl
+[# undef yyerrok
# define yyerrok (yystack->yyerrState = 0)
# undef YYACCEPT
# define YYACCEPT return yyaccept
yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
int yylow = 1;
int yyi;
- YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
+ YYUSE (yyvalp);
+ YYUSE (yylocp);
+]b4_parse_param_use[]dnl
+[ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
(unsigned long int) yyk, yyrule - 1,
(unsigned long int) yyrline[yyrule]);
/* Print the symbols being reduced, and their result. */
[yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
- (void) yyoutput;
+ YYUSE (yyoutput);
+]b4_parse_param_use[]dnl
+[
yyparser.yysymprint_ (yytype, yyvaluep]b4_location_if([, yylocationp])[);
}
]])
b4_parse_param,
[[const char* msg], [msg]])[
{
+]b4_parse_param_use[]dnl
+[
yyparser.error (*yylocationp, msg);
}
const semantic_type* yyvaluep, const location_type* yylocationp)
{
/* Pacify ``unused variable'' warnings. */
- (void) yyvaluep;
- (void) yylocationp;
+ YYUSE (yyvaluep);
+ YYUSE (yylocationp);
/* Backward compatibility, but should be removed eventually. */
std::ostream& cdebug_ = *yycdebug_;
- (void) cdebug_;
+ YYUSE (cdebug_);
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
<< ' ' << yytname[yytype] << " ("