[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: c skeletons: factor the declaration of yylloc and yylval
From: |
Akim Demaille |
Subject: |
FYI: c skeletons: factor the declaration of yylloc and yylval |
Date: |
Thu, 21 Jun 2012 17:14:15 +0200 |
Installed in maint.
From 756257ee865621a8ddce34900043aee1da27d242 Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Sun, 17 Jun 2012 12:10:44 +0200
Subject: [PATCH 2/4] c skeletons: factor the declaration of yylloc and
yylval.
There is one difference: now, even without --defines, we generate
extern declarations for these variables. The factoring is worth it.
* data/c.m4 (b4_declare_yylstype): Declare them.
* data/glr.c, data/yacc.c: Adjust.
---
data/c.m4 | 7 +++++--
data/glr.c | 2 --
data/yacc.c | 2 --
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/data/c.m4 b/data/c.m4
index 78b1232..8c6c497 100644
--- a/data/c.m4
+++ b/data/c.m4
@@ -537,8 +537,8 @@ b4_locations_if([, yylocationp])[]b4_user_args[);
# b4_declare_yylstype
# ------------------
-# Declaration that might either go into the header (if --defines)
-# or open coded in the parser body. Declare YYSTYPE and YYLTYPE.
+# Declarations that might either go into the header (if --defines) or
+# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
m4_define([b4_declare_yylstype],
[[#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
]m4_ifdef([b4_stype],
@@ -566,6 +566,9 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif]])
+
+b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
+]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[]dnl
])
# b4_declare_yydebug
diff --git a/data/glr.c b/data/glr.c
index 9bbf9a7..100a5f2 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -2635,8 +2635,6 @@ b4_copyright([Skeleton interface for Bison GLR parsers in
C],
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
-]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
-]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[
]b4_cpp_guard_close([b4_spec_defines_file])[
]])])
m4_divert_pop(0)
diff --git a/data/yacc.c b/data/yacc.c
index 30c5f67..bd1a4b7 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -2067,8 +2067,6 @@ b4_copyright([Bison interface for Yacc-like parsers in C],
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
-]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
-]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[
]b4_cpp_guard_close([b4_spec_defines_file])[
]])dnl b4_defines_if
m4_divert_pop(0)
--
1.7.10.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: c skeletons: factor the declaration of yylloc and yylval,
Akim Demaille <=