options: rename --defines as --header

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.
This commit is contained in:
Akim Demaille
2020-09-06 13:30:23 +02:00
parent b329f0b5df
commit 75c3746ce2
27 changed files with 78 additions and 63 deletions

View File

@@ -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]
]])

View File

@@ -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,

View File

@@ -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