]> git.saurik.com Git - bison.git/blobdiff - data/c++.m4
warnings: fusion of complain and complain_at
[bison.git] / data / c++.m4
index f1468c708086ebe6bdad5cab3c4728acbeb1ea95..86fd291f4b00672ccdeb51abc3e0621442f479ef 100644 (file)
@@ -86,16 +86,16 @@ m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
              [::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
 
 
-# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
-# -----------------------------------------------------
+# b4_token_enums
+# --------------
 # Output the definition of the tokens as enums.
 m4_define([b4_token_enums],
-[/* Tokens.  */
-   enum yytokentype {
-m4_map_sep([     b4_token_enum], [,
-],
-           [$@])
-   };
+[[enum yytokentype
+      {
+        ]m4_join([,
+        ],
+                 b4_symbol_map([b4_token_enum]))[
+      };]dnl
 ])
 
 
@@ -116,7 +116,7 @@ m4_ifdef([b4_stype],
     };],
 [m4_if(b4_tag_seen_flag, 0,
 [[    typedef int semantic_type;]],
-[[    typedef YYSTYPE semantic_type;]])])])
+[[    typedef ]b4_api_PREFIX[STYPE semantic_type;]])])])
 
 
 # b4_public_types_declare
@@ -124,10 +124,10 @@ m4_ifdef([b4_stype],
 # Define the public types: token, semantic value, location, and so forth.
 # Depending on %define token_lex, may be output in the header or source file.
 m4_define([b4_public_types_declare],
-[[#ifndef YYSTYPE
+[[#ifndef ]b4_api_PREFIX[STYPE
 ]b4_semantic_type_declare[
 #else
-    typedef YYSTYPE semantic_type;
+    typedef ]b4_api_PREFIX[STYPE semantic_type;
 #endif]b4_locations_if([
     /// Symbol locations.
     typedef b4_percent_define_get([[location_type]],
@@ -143,7 +143,7 @@ m4_define([b4_public_types_declare],
     /// Tokens.
     struct token
     {
-      ]b4_token_enums(b4_tokens)[
+      ]b4_token_enums[
     };
 
     /// Token type.
@@ -157,8 +157,8 @@ m4_define([b4_public_types_declare],
       inline symbol_base_type ();
 
       /// Constructor.]b4_locations_if([
-      inline symbol_base_type (const location_type& l)])[;
-      inline symbol_base_type (]b4_args(
+      inline symbol_base_type (const location_type& l);])[
+      inline symbol_base_type (]b4_join(
         [const semantic_type& v],
         b4_locations_if([const location_type& l]))[);
 
@@ -186,12 +186,12 @@ m4_define([b4_public_types_declare],
       inline symbol_type ();
 
       /// Constructor for tokens with semantic value.
-      inline symbol_type (]b4_args([token_type t],
+      inline symbol_type (]b4_join([token_type t],
                                    [const semantic_type& v],
                                    b4_locations_if([const location_type& l]))[);
 
       /// Constructor for valueless tokens.
-      inline symbol_type (]b4_args([token_type t],
+      inline symbol_type (]b4_join([token_type t],
                                    b4_locations_if([const location_type& l]))[);
 
       /// The symbol type.
@@ -235,7 +235,7 @@ m4_define([b4_public_types_define],
 
   template <typename Exact>
   inline
-  ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_args(
+  ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_join(
           [const semantic_type& v],
           b4_locations_if([const location_type& l]))[)
     : value(v)]b4_locations_if([
@@ -276,7 +276,7 @@ m4_define([b4_public_types_define],
   }
 
   inline
-  ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
+  ]b4_parser_class_name[::symbol_type::symbol_type (]b4_join(
                 [token_type t],
                 b4_locations_if([const location_type& l]))[)
     : super_type (]b4_locations_if([l])[)
@@ -285,7 +285,7 @@ m4_define([b4_public_types_define],
   }
 
   inline
-  ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
+  ]b4_parser_class_name[::symbol_type::symbol_type (]b4_join(
                  [token_type t],
                  [const semantic_type& v],
                  b4_locations_if([const location_type& l]))[)
@@ -428,3 +428,32 @@ m4_define([b4_cc_var_decls],
 ], [$@])])
 m4_define([b4_cc_var_decl],
           [    $1;])
+
+
+## ---------##
+## Values.  ##
+## ---------##
+
+# b4_yylloc_default_define
+# ------------------------
+# Define YYLLOC_DEFAULT.
+m4_define([b4_yylloc_default_define],
+[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+   If N is 0, then set CURRENT to the empty location which ends
+   the previous symbol: RHS[0] (always defined).  */
+
+# ifndef YYLLOC_DEFAULT
+#  define YYLLOC_DEFAULT(Current, Rhs, N)                               \
+    do                                                                  \
+      if (N)                                                            \
+        {                                                               \
+          (Current).begin  = YYRHSLOC (Rhs, 1).begin;                   \
+          (Current).end    = YYRHSLOC (Rhs, N).end;                     \
+        }                                                               \
+      else                                                              \
+        {                                                               \
+          (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;      \
+        }                                                               \
+    while (/*CONSTCOND*/ false)
+# endif
+]])