]> git.saurik.com Git - bison.git/commitdiff
b4_semantic_type_declare.
authorAkim Demaille <demaille@gostai.com>
Wed, 31 Dec 2008 11:44:58 +0000 (12:44 +0100)
committerAkim Demaille <demaille@gostai.com>
Mon, 2 Mar 2009 15:08:07 +0000 (16:08 +0100)
* 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
data/c++.m4
data/glr.cc
data/lalr1.cc
data/variant.hh

index 62c28074831c5e402763d941a6ec8e7435a93932..bcf7128490bcba0fb8e74dd8cbe2ce0b8dc6b8f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-03-02  Akim Demaille  <demaille@gostai.com>
+
+       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  <demaille@gostai.com>
 
        Upgrade gnulib.
index ddbb3fa363e0919604f08617cd3707749c1e2033..a64c740e9e655eaa396dd7eb2e54cad3dd92ff90 100644 (file)
@@ -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],
index 254bda1e75b1dfa98c495b34c50a9e2fc6c9ec3f..5cad0b169c60e5e3c0096a95ac561a2c433fc3ad 100644 (file)
@@ -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
index 5c69a1490e6f4e18cb4898a60f2d38eff5f54c6c..2244108178564751d91e3456b45527554ccc1161 100644 (file)
@@ -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([
index 893673383d8fe741f7c0960462a710818da1809e..1534b903d3fbfffd3bb106baa97ab9aaa50b3fa9 100644 (file)
@@ -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])