]> git.saurik.com Git - bison.git/commitdiff
c skeletons: factor the declaration of yylloc and yylval.
authorAkim Demaille <akim@lrde.epita.fr>
Sun, 17 Jun 2012 10:10:44 +0000 (12:10 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Thu, 21 Jun 2012 13:19:43 +0000 (15:19 +0200)
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
data/glr.c
data/yacc.c

index 78b123252833690f0df1d8aa44611ec32e8deb07..8c6c4979659cdb60a12b57c98a75833847425ef6 100644 (file)
--- 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
index 9bbf9a72e936aae0092fc18bf0598f792adc11c3..100a5f2e054a9103776b839c6999b9a271c929bd 100644 (file)
@@ -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)
index 30c5f672aff3a5f3ee959b5f3bfeeccab33617a3..bd1a4b793a78d39ae50f20acc277bdfed6e98008 100644 (file)
@@ -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)