]> git.saurik.com Git - bison.git/commitdiff
skeletons: use header guards.
authorAkim Demaille <akim@lrde.epita.fr>
Fri, 15 Jun 2012 12:21:16 +0000 (14:21 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Fri, 15 Jun 2012 13:33:14 +0000 (15:33 +0200)
* data/glr.c, data/glr.cc, data/yacc.c: here.
* NEWS: Document it.

NEWS
data/glr.c
data/glr.cc
data/yacc.c

diff --git a/NEWS b/NEWS
index fd51b61b61163388870c814ba33de6ac0f3e636e..118aae38592b12d1f81a05558f08f5b70306f2d8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,14 +8,23 @@ GNU Bison NEWS
   and remove the definition of yystype (removal announced since Bison
   1.875).
 
   and remove the definition of yystype (removal announced since Bison
   1.875).
 
-** Changes in regular C parsers (yacc.c):
-
-*** The generated header is included
+** The generated header is included (yacc.c)
 
   Instead of duplicating the content of the generated header (definition of
   YYSTYPE, yyltype etc.), the generated parser now includes it, as was
   already the case for GLR or C++ parsers.
 
 
   Instead of duplicating the content of the generated header (definition of
   YYSTYPE, yyltype etc.), the generated parser now includes it, as was
   already the case for GLR or C++ parsers.
 
+** Header guards (yacc.c, glr.c, glr.cc)
+
+  The generated headers are now guarded, as is already the case for C++
+  parsers (lalr1.cc).  For intance, with --defines=foo.h:
+
+  #ifndef YY_FOO_H
+  # define YY_FOO_H
+  ...
+  #endif /* !YY_FOO_H  */
+
+
 * Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
 
 ** Future changes:
 * Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
 
 ** Future changes:
index 223aa1e9a6f75d55ca22a0c0b5852db60d66a240..d1d61fe63dc102ba1eb4f91d9a479db2bdc7af77 100644 (file)
@@ -166,6 +166,7 @@ m4_define([b4_shared_declarations],
 [b4_percent_code_get([[requires]])[
 ]b4_token_enums(b4_tokens)[
 ]b4_declare_yylstype[
 [b4_percent_code_get([[requires]])[
 ]b4_token_enums(b4_tokens)[
 ]b4_declare_yylstype[
+]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
 ]b4_percent_code_get([[provides]])[]dnl
 ])
 
 ]b4_percent_code_get([[provides]])[]dnl
 ])
 
@@ -472,9 +473,6 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
 };
 
 \f
 };
 
 \f
-/* Prevent warning if -Wmissing-prototypes.  */
-]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[
-
 /* Error token number */
 #define YYTERROR 1
 
 /* Error token number */
 #define YYTERROR 1
 
@@ -2637,15 +2635,12 @@ m4_if(b4_skeleton, ["glr.c"],
 [b4_defines_if(
 [@output(b4_spec_defines_file@)@
 b4_copyright([Skeleton interface for Bison GLR parsers in C],
 [b4_defines_if(
 [@output(b4_spec_defines_file@)@
 b4_copyright([Skeleton interface for Bison GLR parsers in C],
-             [2002-2012])
-
-b4_shared_declarations
-
-b4_pure_if([],
-[[extern YYSTYPE ]b4_prefix[lval;]])
-
-b4_locations_if([b4_pure_if([],
-[extern YYLTYPE ]b4_prefix[lloc;])
-])
-])])
+             [2002-2012])[
+
+]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)
 m4_divert_pop(0)
index d4f21adc8001706e8d6517ac63816a540a63cc75..0bc1f9fa53e0958e926d3ba3921259d0ce08097e 100644 (file)
@@ -230,8 +230,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
 
 /* C++ GLR parser skeleton written by Akim Demaille.  */
 
 
 /* C++ GLR parser skeleton written by Akim Demaille.  */
 
-#ifndef PARSER_HEADER_H
-# define PARSER_HEADER_H
+]b4_cpp_guard_open([b4_spec_defines_file])[
 
 ]b4_percent_code_get([[requires]])[
 
 
 ]b4_percent_code_get([[requires]])[
 
@@ -362,8 +361,6 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
 #endif
 
 ]b4_namespace_close[
 #endif
 
 ]b4_namespace_close[
-
-]b4_percent_code_get([[provides]])[]dnl
-
-[#endif /* ! defined PARSER_HEADER_H */]
-m4_divert_pop(0)
+]b4_percent_code_get([[provides]])[
+]b4_cpp_guard_close([b4_spec_defines_file])[
+]m4_divert_pop(0)
index d5000da0a58f0f5292e61d00f7ec98f6459d05de..7f73c26d736171588054fdf52e3fb648cddca973 100644 (file)
@@ -225,18 +225,10 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
     YYSIZE_T yyes_capacity;]])])
 
 
     YYSIZE_T yyes_capacity;]])])
 
 
-# b4_shared_declarations
-# ----------------------
-# Declaration that might either go into the header (if --defines)
-# or open coded in the parser body.
-m4_define([b4_shared_declarations],
-[b4_percent_code_get([[requires]])[
-]b4_token_enums_defines(b4_tokens)[
-]b4_declare_yylstype[
-]b4_push_if([[
-#ifndef YYPUSH_DECLS
-# define YYPUSH_DECLS
-typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
+# b4_declare_yyparse_push_
+# ------------------------
+m4_define([b4_declare_yyparse_push_],
+[[typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
 enum { YYPUSH_MORE = 4 };
 ]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
 ])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
 enum { YYPUSH_MORE = 4 };
 ]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
 ])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
@@ -251,10 +243,40 @@ b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
 b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
                     [[[void]], []])
 b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
 b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
                     [[[void]], []])
 b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
-                   [[b4_prefix[pstate *yyps]], [[yyps]]])[
-#endif
-]])
-b4_percent_code_get([[provides]])[]dnl
+                   [[b4_prefix[pstate *yyps]], [[yyps]]])dnl
+])
+
+# b4_declare_yyparse_
+# -------------------
+# When not the push parser.
+m4_define([b4_declare_yyparse_],
+[[#ifdef YYPARSE_PARAM
+]b4_c_function_decl(b4_prefix[parse], [int],
+                    [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
+#else /* ! YYPARSE_PARAM */
+]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[
+#endif /* ! YYPARSE_PARAM */]dnl
+])
+
+
+# b4_declare_yyparse
+# ------------------
+m4_define([b4_declare_yyparse],
+[b4_push_if([b4_declare_yyparse_push_],
+            [b4_declare_yyparse_])[]dnl
+])
+
+
+# b4_shared_declarations
+# ----------------------
+# Declaration that might either go into the header (if --defines)
+# or open coded in the parser body.
+m4_define([b4_shared_declarations],
+[b4_percent_code_get([[requires]])[
+]b4_token_enums_defines(b4_tokens)[
+]b4_declare_yylstype[
+]b4_declare_yyparse[
+]b4_percent_code_get([[provides]])[]dnl
 ])
 
 ## -------------- ##
 ])
 
 ## -------------- ##
@@ -1373,20 +1395,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
 }
 #endif /* YYERROR_VERBOSE */
 
 }
 #endif /* YYERROR_VERBOSE */
 
-]b4_yydestruct_generate([b4_c_function_def])b4_push_if([], [[
+]b4_yydestruct_generate([b4_c_function_def])[
 
 
-
-/* Prevent warnings from -Wmissing-prototypes.  */
-#ifdef YYPARSE_PARAM
-]b4_c_function_decl([yyparse], [int],
-                    [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
-#else /* ! YYPARSE_PARAM */
-]b4_c_function_decl([yyparse], [int], b4_parse_param)[
-#endif /* ! YYPARSE_PARAM */]])b4_pure_if([], [
+]b4_pure_if([], [
 
 b4_declare_scanner_communication_variables])[]b4_push_if([[
 
 
 b4_declare_scanner_communication_variables])[]b4_push_if([[
 
-
 struct yypstate
   {]b4_declare_parser_state_variables[
     /* Used to determine if this is the first time this instance has
 struct yypstate
   {]b4_declare_parser_state_variables[
     /* Used to determine if this is the first time this instance has
@@ -2054,8 +2068,11 @@ b4_defines_if(
 [@output(b4_spec_defines_file@)@
 b4_copyright([Bison interface for Yacc-like parsers in C],
              [1984, 1989-1990, 2000-2012])[
 [@output(b4_spec_defines_file@)@
 b4_copyright([Bison interface for Yacc-like parsers in C],
              [1984, 1989-1990, 2000-2012])[
+
+]b4_cpp_guard_open([b4_spec_defines_file])[
 ]b4_shared_declarations[
 ]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
 ]b4_shared_declarations[
 ]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
-]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])dnl
-])dnl b4_defines_if
+]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[
+]b4_cpp_guard_close([b4_spec_defines_file])[
+]])dnl b4_defines_if
 m4_divert_pop(0)
 m4_divert_pop(0)