[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/10] skeletons: avoid empty switch constructs
From: |
Akim Demaille |
Subject: |
[PATCH 04/10] skeletons: avoid empty switch constructs |
Date: |
Mon, 8 Apr 2013 20:35:50 +0200 |
Reported by Rob Conde.
http://lists.gnu.org/archive/html/bug-bison/2013-03/msg00003.html
* data/c.m4 (b4_symbol_actions): Rename as...
(_b4_symbol_actions): this.
(b4_symbol_actions): New wrapper.
Do not emit empty switches.
Adjust all b4_symbol_actions callers.
---
data/c.m4 | 38 +++++++++++++++++++++-----------------
data/glr.cc | 7 +------
data/lalr1.cc | 14 ++------------
3 files changed, 24 insertions(+), 35 deletions(-)
diff --git a/data/c.m4 b/data/c.m4
index a1dc2c5..bcafe42 100644
--- a/data/c.m4
+++ b/data/c.m4
@@ -440,15 +440,15 @@ m4_define([b4_case],
$2
break;])
-# b4_symbol_actions(FILENAME, LINENO,
-# SYMBOL-TAG, SYMBOL-NUM,
-# SYMBOL-ACTION, SYMBOL-TYPENAME)
-# -------------------------------------------------
+# _b4_symbol_actions(FILENAME, LINENO,
+# SYMBOL-TAG, SYMBOL-NUM,
+# SYMBOL-ACTION, SYMBOL-TYPENAME)
+# --------------------------------------------------
# Issue the code for a symbol action (e.g., %printer).
#
# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are
# invoked where $<TYPE-NAME>$ and @$ were specified by the user.
-m4_define([b4_symbol_actions],
+m4_define([_b4_symbol_actions],
[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl
case $4: /* $3 */
b4_syncline([$2], [$1])
@@ -458,6 +458,20 @@ b4_syncline(address@hidden@], address@hidden@])
b4_dollar_popdef[]dnl
])
+# b4_symbol_actions(KIND)
+# -----------------------
+# Emit the symbol actions for KIND ("printers" or "destructors").
+# Dispatch on "yytype".
+m4_define([b4_symbol_actions],
+[m4_ifval(m4_defn([b4_symbol_$1]),
+[[switch (yytype)
+ {
+]m4_map([_b4_symbol_actions], m4_defn([b4_symbol_$1]))[
+ default:
+ break;
+ }]],
+[YYUSE (yytype);])])
+
# b4_yydestruct_generate(FUNCTION-DECLARATOR)
# -------------------------------------------
@@ -487,12 +501,7 @@ b4_parse_param_use[]dnl
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
- switch (yytype)
- {
-]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
- default:
- break;
- }
+ ]b4_symbol_actions([destructors])[
}]dnl
])
@@ -530,12 +539,7 @@ b4_parse_param_use[]dnl
# else
YYUSE (yyoutput);
# endif
- switch (yytype)
- {
-]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
-[ default:
- break;
- }
+ ]b4_symbol_actions([printers])[
}
diff --git a/data/glr.cc b/data/glr.cc
index 49b4fa1..73d0f28 100644
--- a/data/glr.cc
+++ b/data/glr.cc
@@ -167,12 +167,7 @@ m4_pushdef([b4_parse_param],
m4_defn([b4_parse_param_orig]))dnl
std::ostream& yyoutput = debug_stream ();
std::ostream& yyo = yyoutput;
YYUSE (yyo);
- switch (yytype)
- {
- ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
-[ default:
- break;
- }
+ ]b4_symbol_actions([printers])[
}
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 68de8b4..750c3a4 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -422,12 +422,7 @@ do { \
std::ostream& yyo = debug_stream ();
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
- switch (yytype)
- {
- ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
-[ default:
- break;
- }
+ ]b4_symbol_actions([printers])[
}
@@ -454,12 +449,7 @@ do { \
if (yymsg)
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
- switch (yytype)
- {
- ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
- default:
- break;
- }
+ ]b4_symbol_actions([destructors])[
}
void
--
1.8.2
- [PATCH 00/10] {maint} Prepare 2.7.1, Akim Demaille, 2013/04/09
- [PATCH 03/10] lalr1.cc: fix compiler warnings, Akim Demaille, 2013/04/09
- [PATCH 08/10] build: fix VPATH issue, Akim Demaille, 2013/04/09
- [PATCH 06/10] tests: please clang and use ".cc", not ".c", for C++ input, Akim Demaille, 2013/04/09
- [PATCH 07/10] build: avoid clang's colored diagnostics in the test suite, Akim Demaille, 2013/04/09
- [PATCH 01/10] tests: style changes, Akim Demaille, 2013/04/09
- [PATCH 04/10] skeletons: avoid empty switch constructs,
Akim Demaille <=
- [PATCH 10/10] glr.cc: fix a clang warning, Akim Demaille, 2013/04/09
- [PATCH 02/10] yacc.c: do not use __attribute__ unprotected, Akim Demaille, 2013/04/09
- [PATCH 05/10] gnulib: update, Akim Demaille, 2013/04/09
- [PATCH 09/10] maint: update copyright years, Akim Demaille, 2013/04/09