[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: YYUSE user arguments
From: |
Akim Demaille |
Subject: |
FYI: YYUSE user arguments |
Date: |
Mon, 14 Nov 2005 16:18:48 +0100 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
Index: ChangeLog
from Akim Demaille <address@hidden>
"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 <address@hidden>
Index: data/c.m4
===================================================================
RCS file: /cvsroot/bison/bison/data/c.m4,v
retrieving revision 1.40
diff -u -u -r1.40 c.m4
--- data/c.m4 11 Nov 2005 10:36:24 -0000 1.40
+++ data/c.m4 14 Nov 2005 15:18:27 -0000
@@ -95,6 +95,27 @@
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. ##
@@ -348,6 +369,11 @@
[[#]line $1 $2])])
+
+## -------------- ##
+## User actions. ##
+## -------------- ##
+
# b4_symbol_actions(FILENAME, LINENO,
# SYMBOL-TAG, SYMBOL-NUM,
# SYMBOL-ACTION, SYMBOL-TYPENAME)
@@ -386,7 +412,9 @@
{
YYUSE (yyvaluep);
]b4_location_if([ YYUSE (yylocationp);
-])[
+])dnl
+b4_parse_param_use[]dnl
+[
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
@@ -422,8 +450,8 @@
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]);
Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.136
diff -u -u -r1.136 glr.c
--- data/glr.c 14 Nov 2005 14:34:38 -0000 1.136
+++ data/glr.c 14 Nov 2005 15:18:28 -0000
@@ -257,7 +257,11 @@
#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
@@ -868,8 +872,8 @@
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
@@ -1372,7 +1376,10 @@
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. */
Index: data/glr.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.cc,v
retrieving revision 1.1
diff -u -u -r1.1 glr.cc
--- data/glr.cc 14 Nov 2005 08:13:07 -0000 1.1
+++ data/glr.cc 14 Nov 2005 15:18:28 -0000
@@ -53,7 +53,9 @@
[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])[);
}
]])
@@ -70,6 +72,8 @@
b4_parse_param,
[[const char* msg], [msg]])[
{
+]b4_parse_param_use[]dnl
+[
yyparser.error (*yylocationp, msg);
}
@@ -106,11 +110,11 @@
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] << " ("
- FYI: YYUSE user arguments,
Akim Demaille <=