[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/8] api.prefix: do not use #define to handle YYSTYPE_IS_TRIVIAL
From: |
Akim Demaille |
Subject: |
[PATCH 5/8] api.prefix: do not use #define to handle YYSTYPE_IS_TRIVIAL etc. |
Date: |
Wed, 4 Jul 2012 16:53:01 +0200 |
The following mixture is insane:
#define YYSTYPE_IS_TRIVIAL PREFIX_STYPE_IS_TRIVIAL
#if (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)
since, of course YYSTYPE_IS_TRIVIAL is defined. Instead we could
define YYSTYPE_IS_TRIVIAL as PREFIX_STYPE_IS_TRIVIAL only when the
later is defined, but let's avoid stacking CPP on top of M4: rather, use
#if (defined PREFIX_STYPE_IS_TRIVIAL && PREFIX_STYPE_IS_TRIVIAL)
* data/glr.c, data/yacc.c: Use YYSTYPE_IS_TRIVIAL, YYSTYPE_IS_DECLARED,
YYLTYPE_IS_TRIVIAL and YYLTYPE_IS_DECLARED under their api.prefix-renamed
name.
---
data/glr.c | 14 +++++---------
data/yacc.c | 16 ++++++----------
2 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/data/glr.c b/data/glr.c
index 8dd2108..dd02aec 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -190,12 +190,8 @@ b4_copyright([Skeleton implementation for Bison GLR
parsers in C],
b4_percent_code_get([[top]])[
]m4_if(b4_api_prefix, [yy], [],
[[/* Substitute the type names. */
-#define YYSTYPE ]b4_api_PREFIX[STYPE
-#define YYSTYPE_IS_TRIVIAL ]b4_api_PREFIX[STYPE_IS_TRIVIAL
-#define YYSTYPE_IS_DECLARED
]b4_api_PREFIX[STYPE_IS_DECLARED]b4_locations_if([[
-#define YYLTYPE ]b4_api_PREFIX[LTYPE
-#define YYLTYPE_IS_TRIVIAL ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
-#define YYLTYPE_IS_DECLARED ]b4_api_PREFIX[LTYPE_IS_DECLARED]])])[
+#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
+#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
]m4_if(b4_prefix, [yy], [],
[[/* Substitute the variable and function names. */
#define yyparse ]b4_prefix[parse
@@ -613,8 +609,8 @@ int yydebug;
#ifndef YYSTACKEXPANDABLE
# if (! defined __cplusplus \
- || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
- && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))
+ || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL &&
]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
+ && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL &&
]b4_api_PREFIX[STYPE_IS_TRIVIAL))
# define YYSTACKEXPANDABLE 1
# else
# define YYSTACKEXPANDABLE 0
@@ -2319,7 +2315,7 @@ yyrecoverSyntaxError (yyGLRStack*
yystackp]b4_user_formals[)
yychar = YYEMPTY;
yylval = yyval_default;
]b4_locations_if([
-#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
#endif
diff --git a/data/yacc.c b/data/yacc.c
index 3a67914..8623847 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -309,12 +309,8 @@ b4_copyright([Bison implementation for Yacc-like parsers
in C],
b4_percent_code_get([[top]])[]dnl
m4_if(b4_api_prefix, [yy], [],
[[/* Substitute the type names. */
-#define YYSTYPE ]b4_api_PREFIX[STYPE
-#define YYSTYPE_IS_TRIVIAL ]b4_api_PREFIX[STYPE_IS_TRIVIAL
-#define YYSTYPE_IS_DECLARED
]b4_api_PREFIX[STYPE_IS_DECLARED]b4_locations_if([[
-#define YYLTYPE ]b4_api_PREFIX[LTYPE
-#define YYLTYPE_IS_TRIVIAL ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
-#define YYLTYPE_IS_DECLARED ]b4_api_PREFIX[LTYPE_IS_DECLARED]])])[
+#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
+#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
]m4_if(b4_prefix, [yy], [],
[[/* Substitute the variable and function names. */]b4_pull_if([[
#define yyparse ]b4_prefix[parse]])b4_push_if([[
@@ -498,8 +494,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
- || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL &&
YYLTYPE_IS_TRIVIAL \
- && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+ || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL &&
]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
+ && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL &&
]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -776,7 +772,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
-# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
@@ -1585,7 +1581,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
yyvsp = yyvs;]b4_locations_if([[
yylsp = yyls;
-#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
--
1.7.11.1
- [PATCH 0/8] Various improvements prompted by api.prefix, Akim Demaille, 2012/07/04
- [PATCH 3/8] c++: fewer #includes in the headers., Akim Demaille, 2012/07/04
- [PATCH 5/8] api.prefix: do not use #define to handle YYSTYPE_IS_TRIVIAL etc.,
Akim Demaille <=
- [PATCH 7/8] glr.cc: do not override C++ definitions by C macros., Akim Demaille, 2012/07/04
- [PATCH 1/8] tests: more logs., Akim Demaille, 2012/07/04
- [PATCH 6/8] YYLLOC_DEFAULT: factor, and don't export it in headers., Akim Demaille, 2012/07/04
- [PATCH 2/8] glr.cc: formatting changes., Akim Demaille, 2012/07/04
- [PATCH 4/8] tests: portability fixes., Akim Demaille, 2012/07/04
- [PATCH 8/8] tests: headers.at: strengthen., Akim Demaille, 2012/07/04