[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] b4_semantic_type_declare.
From: |
Akim Demaille |
Subject: |
[PATCH] b4_semantic_type_declare. |
Date: |
Mon, 02 Mar 2009 15:12:15 -0000 |
* data/c++.m4 (b4_semantic_type_declare): New.
Factors and generalizes what was in glr.cc and lalr1.cc.
* data/variant.hh (b4_semantic_type_declare): Redefine it for
variants.
* data/lalr1.cc, data/glr.cc: Use it.
---
ChangeLog | 9 +++++++++
data/c++.m4 | 14 ++++++++++++++
data/glr.cc | 10 +---------
data/lalr1.cc | 16 +---------------
data/variant.hh | 12 ++++++++++++
5 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 62c2807..bcf7128 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-03-02 Akim Demaille <address@hidden>
+
+ b4_semantic_type_declare.
+ * data/c++.m4 (b4_semantic_type_declare): New.
+ Factors and generalizes what was in glr.cc and lalr1.cc.
+ * data/variant.hh (b4_semantic_type_declare): Redefine it for
+ variants.
+ * data/lalr1.cc, data/glr.cc: Use it.
+
2009-02-26 Akim Demaille <address@hidden>
Upgrade gnulib.
diff --git a/data/c++.m4 b/data/c++.m4
index ddbb3fa..a64c740 100644
--- a/data/c++.m4
+++ b/data/c++.m4
@@ -97,6 +97,20 @@ m4_map_sep([ b4_token_enum], [,
## Semantic Values. ##
## ----------------- ##
+# b4_semantic_type_declare
+# ------------------------
+# Declare semantic_type.
+m4_define([b4_semantic_type_declare],
+[ /// Symbol semantic values.
+m4_ifdef([b4_stype],
+[ union semantic_type
+ {b4_user_stype
+ };],
+[m4_if(b4_tag_seen_flag, 0,
+[[ typedef int semantic_type;]],
+[[ typedef YYSTYPE semantic_type;]])])])
+
+
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
# ----------------------------------------------
m4_define([b4_variant_if],
diff --git a/data/glr.cc b/data/glr.cc
index 254bda1..5cad0b1 100644
--- a/data/glr.cc
+++ b/data/glr.cc
@@ -266,16 +266,8 @@ b4_copyright([Skeleton interface for Bison GLR parsers in
C++],
class ]b4_parser_class_name[
{
public:
- /// Symbol semantic values.
#ifndef YYSTYPE
-]m4_ifdef([b4_stype],
-[ union semantic_type
- {
-b4_user_stype
- };],
-[m4_if(b4_tag_seen_flag, 0,
-[[ typedef int semantic_type;]],
-[[ typedef YYSTYPE semantic_type;]])])[
+]b4_semantic_type_declare[
#else
typedef YYSTYPE semantic_type;
#endif
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 5c69a14..2244108 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -389,21 +389,7 @@ do {
\
{
public:
#ifndef YYSTYPE
-]b4_variant_if(
-[ /// An auxiliary type to compute the largest semantic type.
- union union_type
- {]b4_type_foreach([b4_char_sizeof])[};
-
- /// Symbol semantic values.
- typedef variant<sizeof(union_type)> semantic_type;],
-[ /// Symbol semantic values.
-m4_ifdef([b4_stype],
-[ union semantic_type
- {b4_user_stype
- };],
-[m4_if(b4_tag_seen_flag, 0,
-[[ typedef int semantic_type;]],
-[[ typedef YYSTYPE semantic_type;]])])])[
+]b4_semantic_type_declare[
#else
typedef YYSTYPE semantic_type;
#endif]b4_locations_if([
diff --git a/data/variant.hh b/data/variant.hh
index 8936733..1534b90 100644
--- a/data/variant.hh
+++ b/data/variant.hh
@@ -189,6 +189,18 @@ m4_define([b4_variant_definition],
## -------------------------- ##
+# b4_semantic_type_declare
+# ------------------------
+# Declare semantic_type.
+m4_define([b4_semantic_type_declare],
+[ /// An auxiliary type to compute the largest semantic type.
+ union union_type
+ {]b4_type_foreach([b4_char_sizeof])[};
+
+ /// Symbol semantic values.
+ typedef variant<sizeof(union_type)> semantic_type;])
+
+
# How the semantic value is extracted when using variants.
# b4_symbol_value(VAL, [TYPE])
--
1.6.2.rc0.35.g1b53
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] b4_semantic_type_declare.,
Akim Demaille <=