[PATCH 1/4] options: rename --defines as --header

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
The name "defines" is incorrect, the generated file contains far more
than just #defines.

* src/getargs.h, src/getargs.c (-H, --header): New option.
With optional argument, just like --defines, --xml, etc.
(defines_flag): Rename as...
(header_flag): this.
Adjust dependencies.
* data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.c,
* data/skeletons/glr.cc, data/skeletons/glr2.cc, data/skeletons/lalr1.cc,
* data/skeletons/yacc.c:
Adjust.
* examples, doc/bison.texi: Adjust.
* tests/headers.at, tests/local.at, tests/output.at: Convert most
tests from using --defines to using --header.
---
 NEWS                             |  7 +++++++
 data/skeletons/bison.m4          |  2 +-
 data/skeletons/c.m4              |  2 +-
 data/skeletons/glr.c             |  6 +++---
 data/skeletons/glr.cc            |  4 ++--
 data/skeletons/glr2.cc           |  6 +++---
 data/skeletons/lalr1.cc          |  6 +++---
 data/skeletons/lalr1.java        |  2 +-
 data/skeletons/location.cc       |  4 ++--
 data/skeletons/stack.hh          |  2 +-
 data/skeletons/yacc.c            |  6 +++---
 doc/bison.texi                   | 17 +++++++++++------
 examples/c/bistromathic/Makefile |  2 +-
 examples/c/calc/Makefile         |  2 +-
 examples/c/lexcalc/Makefile      |  2 +-
 examples/c/pushcalc/Makefile     |  2 +-
 examples/c/reccalc/Makefile      |  2 +-
 src/files.c                      |  4 ++--
 src/files.h                      |  4 ++--
 src/getargs.c                    | 28 ++++++++++++++--------------
 src/getargs.h                    |  2 +-
 src/output.c                     |  2 +-
 src/parse-gram.c                 |  4 ++--
 src/parse-gram.y                 |  4 ++--
 tests/headers.at                 |  3 +--
 tests/local.at                   |  4 ++--
 tests/output.at                  | 12 ++++++++----
 27 files changed, 78 insertions(+), 63 deletions(-)

diff --git a/NEWS b/NEWS
index b155644b..3531e2fa 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,13 @@ GNU Bison NEWS
 
 ** Changes
 
+** New features
+
+*** Option -H, --header
+
+  The option -H/--header replaces the option --defines (maintained for
+  backward compatibility).
+
 *** A C++ native GLR parser
 
   A new version of the generated C++ GLR parser was added as "glr2.cc". It
diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4
index 0591de5c..37e2b849 100644
--- a/data/skeletons/bison.m4
+++ b/data/skeletons/bison.m4
@@ -391,9 +391,9 @@ m4_define([b4_$3_if],
 # b4_FLAG_if(IF-TRUE, IF-FALSE)
 # -----------------------------
 # Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
-b4_define_flag_if([defines])            # Whether headers are requested.
 b4_define_flag_if([glr])                # Whether a GLR parser is requested.
 b4_define_flag_if([has_translations])   # Whether some tokens are internationalized.
+b4_define_flag_if([header])             # Whether a header is requested.
 b4_define_flag_if([nondeterministic])   # Whether conflicts should be handled.
 b4_define_flag_if([token_table])        # Whether yytoken_table is demanded.
 b4_define_flag_if([yacc])               # Whether POSIX Yacc is emulated.
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index c41db4d1..bf5ddfaa 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -947,7 +947,7 @@ struct ]b4_api_PREFIX[LTYPE
 
 # b4_declare_yylstype
 # -------------------
-# Declarations that might either go into the header (if --defines) or
+# Declarations that might either go into the header (if --header) or
 # in the parser body.  Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
 m4_define([b4_declare_yylstype],
 [b4_value_type_define[]b4_locations_if([
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index a50f1804..c405a39d 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -151,7 +151,7 @@ m4_define([b4_rhs_location],
 
 # b4_shared_declarations
 # ----------------------
-# Declaration that might either go into the header (if --defines)
+# Declaration that might either go into the header (if --header)
 # or open coded in the parser body.  glr.cc has its own definition.
 m4_if(b4_skeleton, ["glr.c"],
 [m4_define([b4_shared_declarations],
@@ -185,7 +185,7 @@ int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)],
 
 # glr.cc produces its own header.
 b4_glr_cc_if([],
-[b4_defines_if(
+[b4_header_if(
 [b4_output_begin([b4_spec_header_file])
 b4_copyright([Skeleton interface for Bison GLR parsers in C],
              [2002-2015, 2018-2020])[
@@ -228,7 +228,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
 ]b4_cast_define[
 ]b4_null_define[
 
-]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
+]b4_header_if([[#include "@basename(]b4_spec_header_file[@)"]],
                [b4_shared_declarations])[
 
 ]b4_glr_cc_if([b4_glr_cc_setup],
diff --git a/data/skeletons/glr.cc b/data/skeletons/glr.cc
index 56279f42..8a789b9a 100644
--- a/data/skeletons/glr.cc
+++ b/data/skeletons/glr.cc
@@ -263,7 +263,7 @@ b4_symbol_foreach([b4_undef_symbol_kind])dnl
 
 # b4_shared_declarations(hh|cc)
 # -----------------------------
-# Declaration that might either go into the header (if --defines, $1 = hh)
+# Declaration that might either go into the header (if --header, $1 = hh)
 # or in the implementation file.
 m4_define([b4_shared_declarations],
 [m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
@@ -378,7 +378,7 @@ b4_percent_code_get([[requires]])[
 ]m4_popdef([b4_parse_param])dnl
 ])[
 
-]b4_defines_if(
+]b4_header_if(
 [b4_output_begin([b4_spec_header_file])
 b4_copyright([Skeleton interface for Bison GLR parsers in C++],
              [2002-2015, 2018-2020])[
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index a7f2d129..b2ce9ea9 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -101,7 +101,7 @@ m4_define([b4_glr_cc_cleanup],
 
 # b4_shared_declarations(hh|cc)
 # -----------------------------
-# Declaration that might either go into the header (if --defines, $1 = hh)
+# Declaration that might either go into the header (if --header, $1 = hh)
 # or in the implementation file.
 m4_define([b4_shared_declarations],
 [m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
@@ -321,7 +321,7 @@ const std::ptrdiff_t strong_index_alias<T>::INVALID_INDEX =
 ]m4_popdef([b4_parse_param])dnl
 ])[
 
-]b4_defines_if(
+]b4_header_if(
 [b4_output_begin([b4_spec_header_file])
 b4_copyright([Skeleton interface for Bison GLR parsers in C++],
              [2002-2015, 2018-2020])[
@@ -495,7 +495,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
 
 ]b4_null_define[
 
-]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
+]b4_header_if([[#include "@basename(]b4_spec_header_file[@)"]],
                [b4_shared_declarations])[
 
 ]b4_glr_cc_setup[
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index b95f9aa9..fe8f13d0 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -174,7 +174,7 @@ b4_variant_if([m4_include(b4_skeletonsdir/[variant.hh])])
 
 # b4_shared_declarations(hh|cc)
 # -----------------------------
-# Declaration that might either go into the header (if --defines, $1 = hh)
+# Declaration that might either go into the header (if --header, $1 = hh)
 # or in the implementation file.
 m4_define([b4_shared_declarations],
 [b4_percent_code_get([[requires]])[
@@ -500,7 +500,7 @@ m4_define([b4_shared_declarations],
 ## Output files.  ##
 ## -------------- ##
 
-b4_defines_if(
+b4_header_if(
 [b4_output_begin([b4_spec_header_file])
 b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
 [
@@ -530,7 +530,7 @@ m4_if(b4_prefix, [yy], [],
 
 ]b4_user_pre_prologue[
 
-]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
+]b4_header_if([[#include "@basename(]b4_spec_header_file[@)"]],
                [b4_shared_declarations([cc])])[
 
 ]b4_user_post_prologue[
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index b85c16a0..d749226f 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -17,7 +17,7 @@
 
 m4_include(b4_skeletonsdir/[java.m4])
 
-b4_defines_if([b4_complain([%defines does not make sense in Java])])
+b4_header_if([b4_complain([%defines does not make sense in Java])])
 
 m4_define([b4_symbol_no_destructor_assert],
 [b4_symbol_if([$1], [has_destructor],
diff --git a/data/skeletons/location.cc b/data/skeletons/location.cc
index 33c9e50d..dc1be6db 100644
--- a/data/skeletons/location.cc
+++ b/data/skeletons/location.cc
@@ -22,7 +22,7 @@ m4_pushdef([b4_copyright_years],
 # b4_position_file
 # ----------------
 # Name of the file containing the position class, if we want this file.
-b4_defines_if([b4_required_version_if([302], [],
+b4_header_if([b4_required_version_if([302], [],
                                       [m4_define([b4_position_file], [position.hh])])])])
 
 
@@ -32,7 +32,7 @@ b4_defines_if([b4_required_version_if([302], [],
 # if we want this file.
 b4_percent_define_check_file([b4_location_file],
                              [[api.location.file]],
-                             b4_defines_if([[location.hh]]))
+                             b4_header_if([[location.hh]]))
 
 # b4_location_include
 # -------------------
diff --git a/data/skeletons/stack.hh b/data/skeletons/stack.hh
index 0fd36258..4e379e19 100644
--- a/data/skeletons/stack.hh
+++ b/data/skeletons/stack.hh
@@ -19,7 +19,7 @@
 # b4_stack_file
 # -------------
 # Name of the file containing the stack class, if we want this file.
-b4_defines_if([b4_required_version_if([302], [],
+b4_header_if([b4_required_version_if([302], [],
                                       [m4_define([b4_stack_file], [stack.hh])])])
 
 
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index c695a039..5e9d7345 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -293,7 +293,7 @@ m4_define([b4_declare_yyparse],
 
 # b4_shared_declarations
 # ----------------------
-# Declaration that might either go into the header (if --defines)
+# Declaration that might either go into the header (if --header)
 # or open coded in the parser body.
 m4_define([b4_shared_declarations],
 [b4_cpp_guard_open([b4_spec_mapped_header_file])[
@@ -330,13 +330,13 @@ m4_if(b4_spec_header_file, [y.tab.h], [],
 ## -------------- ##
 
 
-b4_defines_if([[
+b4_header_if([[
 ]b4_output_begin([b4_spec_header_file])[
 ]b4_copyright([Bison interface for Yacc-like parsers in C])[
 ]b4_disclaimer[
 ]b4_shared_declarations[
 ]b4_output_end[
-]])# b4_defines_if
+]])# b4_header_if
 
 b4_output_begin([b4_parser_file_name])[
 ]b4_copyright([Bison implementation for Yacc-like parsers in C])[
diff --git a/doc/bison.texi b/doc/bison.texi
index 82ec5b95..c73a28d2 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -6092,7 +6092,7 @@ std::string} as default).
 
 @item Purpose: Specify how the generated parser should include the generated header.
 
-Historically, when option @option{-D}/@option{--defines} was used,
+Historically, when option @option{-d} or @option{--header} was used,
 @command{bison} generated a header and pasted an exact copy of it into the
 generated parser implementation file.  Since Bison 3.6, it is
 @code{#include}d as @samp{"@var{basename}.h"}, instead of duplicated, unless
@@ -11798,15 +11798,19 @@ Options controlling the output.
 
 @c Please, keep this ordered as in 'bison --help'.
 @table @option
-@item --defines[=@var{file}]
+@item -H [@var{file}]
+@itemx --header=[@var{file}]
 Pretend that @code{%defines} was specified, i.e., write an extra output file
 containing definitions for the token kind names defined in the grammar, as
 well as a few other declarations.  @xref{Decl Summary}.
 
+@item --defines[=@var{file}]
+Historical name for option @option{--header}.
+
 @item -d
-This is the same as @option{--defines} except @option{-d} does not accept a
-@var{file} argument since POSIX Yacc requires that @option{-d} can be bundled
-with other short options.
+This is the same as @option{--header} except @option{-d} does not accept a
+@var{file} argument since POSIX Yacc requires that @option{-d} can be
+bundled with other short options.
 
 @item -b @var{file-prefix}
 @itemx --file-prefix=@var{prefix}
@@ -13794,7 +13798,8 @@ GLR parsers are currently unsupported in Java.  Do not use the
 @code{glr-parser} directive.
 
 No header file can be generated for Java parsers.  Do not use the
-@code{%defines} directive or the @option{-d}/@option{--defines} options.
+@code{%defines} directive or the @option{-d}/@option{-H}/@option{--header}
+options.
 
 @c FIXME: Possible code change.
 Currently, support for tracing is always compiled in.  Thus the
diff --git a/examples/c/bistromathic/Makefile b/examples/c/bistromathic/Makefile
index 99c8dcfc..9efeeb8d 100644
--- a/examples/c/bistromathic/Makefile
+++ b/examples/c/bistromathic/Makefile
@@ -19,7 +19,7 @@ LIBS = -lreadline -lm # In some environments, -lintl is needed.
 all: $(BASE)
 
 %.c %.h %.xml %.gv: %.y
-	$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
+	$(BISON) $(BISONFLAGS) --header --xml --graph=$*.gv -o $*.c $<
 
 $(BASE): parse.o
 	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
diff --git a/examples/c/calc/Makefile b/examples/c/calc/Makefile
index 6221ca9e..3a32d012 100644
--- a/examples/c/calc/Makefile
+++ b/examples/c/calc/Makefile
@@ -8,7 +8,7 @@ XSLTPROC = xsltproc
 all: $(BASE)
 
 %.c %.h %.xml %.gv: %.y
-	$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
+	$(BISON) $(BISONFLAGS) --header --xml --graph=$*.gv -o $*.c $<
 
 $(BASE): $(BASE).o
 	$(CC) $(CFLAGS) -o $@ $^
diff --git a/examples/c/lexcalc/Makefile b/examples/c/lexcalc/Makefile
index eccc8767..88badb7b 100644
--- a/examples/c/lexcalc/Makefile
+++ b/examples/c/lexcalc/Makefile
@@ -9,7 +9,7 @@ XSLTPROC = xsltproc
 all: $(BASE)
 
 %.c %.h %.xml %.gv: %.y
-	$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
+	$(BISON) $(BISONFLAGS) --header --xml --graph=$*.gv -o $*.c $<
 
 %.c: %.l
 	$(FLEX) $(FLEXFLAGS) -o$@ $<
diff --git a/examples/c/pushcalc/Makefile b/examples/c/pushcalc/Makefile
index 6221ca9e..3a32d012 100644
--- a/examples/c/pushcalc/Makefile
+++ b/examples/c/pushcalc/Makefile
@@ -8,7 +8,7 @@ XSLTPROC = xsltproc
 all: $(BASE)
 
 %.c %.h %.xml %.gv: %.y
-	$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
+	$(BISON) $(BISONFLAGS) --header --xml --graph=$*.gv -o $*.c $<
 
 $(BASE): $(BASE).o
 	$(CC) $(CFLAGS) -o $@ $^
diff --git a/examples/c/reccalc/Makefile b/examples/c/reccalc/Makefile
index a64ceedb..ff338003 100644
--- a/examples/c/reccalc/Makefile
+++ b/examples/c/reccalc/Makefile
@@ -9,7 +9,7 @@ XSLTPROC = xsltproc
 all: $(BASE)
 
 %.c %.h %.xml %.gv: %.y
-	$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
+	$(BISON) $(BISONFLAGS) --header --xml --graph=$*.gv -o $*.c $<
 
 %.c %.h: %.l
 	$(FLEX) $(FLEXFLAGS) -o$*.c --header=$*.h $<
diff --git a/src/files.c b/src/files.c
index 1f72730d..6675bb2c 100644
--- a/src/files.c
+++ b/src/files.c
@@ -56,7 +56,7 @@ location spec_name_prefix_loc = EMPTY_LOCATION_INIT;
 char *spec_verbose_file = NULL;  /* for --verbose. */
 char *spec_graph_file = NULL;    /* for -g. */
 char *spec_xml_file = NULL;      /* for -x. */
-char *spec_header_file = NULL;  /* for --defines. */
+char *spec_header_file = NULL;   /* for --header. */
 char *spec_mapped_header_file = NULL;
 char *parser_file_name;
 
@@ -411,7 +411,7 @@ compute_output_file_names (void)
      ? xstrdup (spec_outfile)
      : concat2 (all_but_ext, src_extension));
 
-  if (defines_flag)
+  if (header_flag)
     {
       if (! spec_header_file)
         spec_header_file = concat2 (all_but_ext, header_extension);
diff --git a/src/files.h b/src/files.h
index 22d1d750..dafdbc95 100644
--- a/src/files.h
+++ b/src/files.h
@@ -47,10 +47,10 @@ extern char *spec_graph_file;
 /* File name specified for the xml output.  */
 extern char *spec_xml_file;
 
-/* File name specified with --defines.  */
+/* File name specified with --header.  */
 extern char *spec_header_file;
 
-/* File name specified with --defines, adjusted for mapped prefixes. */
+/* File name specified with --header, adjusted for mapped prefixes. */
 extern char *spec_mapped_header_file;
 
 /* Directory prefix of output file names.  */
diff --git a/src/getargs.c b/src/getargs.c
index a15c07b5..df2c6da1 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -38,7 +38,7 @@
 #include "output.h"
 #include "uniqstr.h"
 
-bool defines_flag = false;
+bool header_flag = false;
 bool graph_flag = false;
 bool xml_flag = false;
 bool no_lines_flag = false;
@@ -422,11 +422,9 @@ Tuning the Parser:\n\
 "), stdout);
       putc ('\n', stdout);
 
-      /* Keep -d and --defines separate so that ../build-aux/cross-options.pl
-       * won't assume that -d also takes an argument.  */
       fputs (_("\
 Output Files:\n\
-      --defines[=FILE]          also produce a header file\n\
+  -H, --header=[FILE]           also produce a header file\n\
   -d                            likewise but cannot specify FILE (for POSIX Yacc)\n\
   -r, --report=THINGS           also produce details on the automaton\n\
       --report-file=FILE        write report to FILE\n\
@@ -545,6 +543,7 @@ language_argmatch (char const *arg, int prio, location loc)
 static char const short_options[] =
   "D:"
   "F:"
+  "H::"
   "L:"
   "S:"
   "T::"
@@ -609,6 +608,7 @@ static struct option const long_options[] =
   { "yacc",           no_argument,         0, 'y' },
 
   /* Output Files. */
+  { "header",          optional_argument,   0,   'H' },
   { "defines",         optional_argument,   0,   'd' },
   { "report",          required_argument,   0,   'r' },
   { "report-file",     required_argument,   0,   REPORT_FILE_OPTION },
@@ -719,6 +719,16 @@ getargs (int argc, char *argv[])
         }
         break;
 
+      case 'H':
+      case 'd':
+        header_flag = true;
+        if (optarg)
+          {
+            free (spec_header_file);
+            spec_header_file = xstrdup (optarg);
+          }
+        break;
+
       case 'L':
         language_argmatch (optarg, command_line_prio, loc);
         break;
@@ -763,16 +773,6 @@ getargs (int argc, char *argv[])
         spec_file_prefix = optarg;
         break;
 
-      case 'd':
-        /* Here, the -d and --defines options are differentiated.  */
-        defines_flag = true;
-        if (optarg)
-          {
-            free (spec_header_file);
-            spec_header_file = xstrdup (optarg);
-          }
-        break;
-
       case 'g':
         graph_flag = true;
         if (optarg)
diff --git a/src/getargs.h b/src/getargs.h
index 53826687..c8b2f659 100644
--- a/src/getargs.h
+++ b/src/getargs.h
@@ -34,7 +34,7 @@ extern int skeleton_prio;
 /* for -I */
 extern char const *include;
 
-extern bool defines_flag;               /* for -d */
+extern bool header_flag;                /* for -d/-H */
 extern bool graph_flag;                 /* for -g */
 extern bool xml_flag;                   /* for -x */
 extern bool no_lines_flag;              /* for -l */
diff --git a/src/output.c b/src/output.c
index d550c470..64d40e51 100644
--- a/src/output.c
+++ b/src/output.c
@@ -810,7 +810,7 @@ prepare (void)
   MUSCLE_INSERT_INT ("required_version", required_version);
 
   /* Flags. */
-  MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
+  MUSCLE_INSERT_BOOL ("header_flag", header_flag);
   MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
   MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
   MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
diff --git a/src/parse-gram.c b/src/parse-gram.c
index d8eb81cc..d3318872 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -2075,7 +2075,7 @@ yyreduce:
     break;
 
   case 9: /* prologue_declaration: "%defines"  */
-                                   { defines_flag = true; }
+                                   { header_flag = true; }
     break;
 
   case 10: /* prologue_declaration: "%defines" "string"  */
@@ -2938,7 +2938,7 @@ add_param (param_type type, char *decl, location loc)
 static void
 handle_defines (char const *value)
 {
-  defines_flag = true;
+  header_flag = true;
   char *file = unquote (value);
   spec_header_file = xstrdup (file);
   gram_scanner_last_string_free ();
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 925e0773..8c71fffe 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -339,7 +339,7 @@ prologue_declaration:
       muscle_percent_define_insert ($2, @$, $3.kind, $3.chars,
                                     MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
     }
-| "%defines"                       { defines_flag = true; }
+| "%defines"                       { header_flag = true; }
 | "%defines" STRING                { handle_defines ($2); }
 | "%error-verbose"                 { handle_error_verbose (&@$, $1); }
 | "%expect" INT_LITERAL            { expected_sr_conflicts = $2; }
@@ -949,7 +949,7 @@ add_param (param_type type, char *decl, location loc)
 static void
 handle_defines (char const *value)
 {
-  defines_flag = true;
+  header_flag = true;
   char *file = unquote (value);
   spec_header_file = xstrdup (file);
   gram_scanner_last_string_free ();
diff --git a/tests/headers.at b/tests/headers.at
index bf48120b..38eb8066 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -47,7 +47,6 @@ dummy: %empty;
 ])
 
 AT_BISON_CHECK([--defines=$1.h --output=$1.c $1.y])
-
 AT_COMPILE([$1.o], [-I. -c $1.c])
 
 AT_BISON_OPTION_POPDEFS
@@ -83,7 +82,7 @@ AT_DATA_GRAMMAR([input.y],
 exp: %empty;
 ]])
 
-AT_BISON_CHECK([--defines -o input.c input.y], [], [],
+AT_BISON_CHECK([--header -o input.c input.y], [], [],
 [[input.y:11.1-18: warning: deprecated directive: '%name-prefix "my_"', use '%define api.prefix {my_}' [-Wdeprecated]
 input.y: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
 ]])
diff --git a/tests/local.at b/tests/local.at
index 66a59c59..83949f24 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -1506,7 +1506,7 @@ m4_define([AT_PARSER_CHECK],
 #
 # If TEST-SPEC contains the attribute no-xml, then invoke bison using
 # AT_BISON_CHECK_NO_XML.  Otherwise, invoke bison using AT_BISON_CHECK.
-# On the bison command-line, specify `--report=all --defines'.  Check
+# On the bison command-line, specify `--report=all --header'.  Check
 # that Bison exits with value 0, has no stdout, and has stderr
 # BISON-STDERR.
 #
@@ -1600,7 +1600,7 @@ yylex (void)
 
 m4_if(m4_index(m4_quote($3), [no-xml]), -1,
       [AT_BISON_CHECK],
-      [AT_BISON_CHECK_NO_XML])([[-Wall --report=all,no-cex --defines -o input.c input.y]],
+      [AT_BISON_CHECK_NO_XML])([[-Wall --report=all,no-cex --header -o input.c input.y]],
                                [0], [], m4_dquote($7))
 
 m4_if(m4_index(m4_quote($3), [last-state]), -1,
diff --git a/tests/output.at b/tests/output.at
index 5af1e914..2ef33354 100644
--- a/tests/output.at
+++ b/tests/output.at
@@ -132,6 +132,10 @@ AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
                 [foo.c foo.h foo.output])
 
+AT_CHECK_OUTPUT([foo.yy], [],
+                [--header=foo.hpp -o foo.c++],
+                [foo.c++ foo.hpp])
+
 AT_CHECK_OUTPUT([foo.yy], [],
                 [--defines=foo.hpp -o foo.c++],
                 [foo.c++ foo.hpp])
@@ -147,14 +151,14 @@ AT_CHECK_OUTPUT([foo.yy], [],
 # Do not generate code when there are early errors (even warnings as
 # errors).
 AT_CHECK_OUTPUT([foo.y], [%type <foo> useless],
-                [--defines --graph --xml --report=all -Wall -Werror],
+                [--header --graph --xml --report=all -Wall -Werror],
                 [foo.dot foo.output foo.xml],
                 [1])
 
 # Do not generate code when there are late errors (even warnings as
 # errors).
 AT_CHECK_OUTPUT([foo.y], [%define useless],
-                [--defines --graph --xml --report=all -Wall -Werror],
+                [--header --graph --xml --report=all -Wall -Werror],
                 [foo.dot foo.output foo.xml],
                 [1])
 
@@ -284,7 +288,7 @@ AT_DATA_GRAMMAR([glr.y],
 %%
 start: {};
 ]])
-AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" glr.y])
+AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --header="AS_ESCAPE([$1.h])" glr.y])
 AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
 AT_COMPILE([glr.o], [-c "AS_ESCAPE([$1.c])"])
 $2
@@ -295,7 +299,7 @@ AT_DATA_GRAMMAR([cxx.y],
 %%
 start: {};
 ]])
-AT_BISON_CHECK([-o "AS_ESCAPE([$1.cc])" --defines="AS_ESCAPE([$1.hh])" cxx.y])
+AT_BISON_CHECK([-o "AS_ESCAPE([$1.cc])" --header="AS_ESCAPE([$1.hh])" cxx.y])
 AT_CHECK([ls "AS_ESCAPE([$1.cc])" "AS_ESCAPE([$1.hh])"], [], [ignore])
 AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.cc])"])
 $2
-- 
2.28.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.