C++: let %require "3.2" disable the generation of obsolete files

The files stack.hh and position.hh are deprecated.  Rather than
devoting specify %define variables to discard them (api.position.file
and api.stack.file), and rather than having to use special rules when
api.location.file is used, let's simply decide that from %require
"3.2" onwards, these files will not be generated.

The only noticeable thing here is that, in order to be able to check
the behavior of %require "3.2", to have this version (which is still
3.1-*) to accept %require "3.2".

* src/gram.h, src/gram.c (required_version): New.
* src/parse-gram.y (version_check): Set it.
* src/output.c (prepare): Pass it m4.
* data/bison.m4 (b4_required_version_if): Receive it and use it.
* data/location.cc, data/stack.hh: Replace the api.*.file with only
required version comparison.
* tests/input.at: No longer check api.stack.file and api.position.file.
* NEWS, doc/bison.texi: Don't mention them.
Document the %require 3.2 behavior.
* tests/output.at: Use %require 3.2 instead.
This commit is contained in:
Akim Demaille
2018-10-15 14:04:00 +02:00
parent 2b0a9c69df
commit ea31f21fd8
11 changed files with 76 additions and 122 deletions

View File

@@ -4788,6 +4788,14 @@ status 63).
%require "@var{version}"
@end example
Some deprecated behaviors are disabled for some required @var{version}:
@table @code
@item "3.2"
The C++ deprecated files @file{position.hh} and @file{stack.hh} are no
longer generated.
@end table
@node Token Decl
@subsection Token Type Names
@cindex declaring token type names
@@ -5834,9 +5842,6 @@ in @var{file}. This file name can be relative (to where the parser file is
output) or absolute.
@end table
Defining it implies @samp{%define api.position.file none} and @samp{%define
api.stack.file none}.
@item Default Value:
Not applicable if locations are not enabled, or if a user location type is
specified (see @code{api.location.type}). Otherwise, Bison's
@@ -5893,28 +5898,6 @@ Introduced in Bison 2.7 for C, C++ and Java. Introduced under the name
@end itemize
@end deffn
@c ================================================== api.position.file
@deffn {Directive} {%define api.position.file} @code{none}
@itemize @bullet
@item Language(s): C++
@item Purpose:
Disable the generation of the legacy file @file{position.hh}. The class
@code{position} is now defined where the class @code{location} is.
@item Accepted Values: @code{none}
@item Default Value:
@code{none} if @code{api.location.file} is defined, otherwise a useless
@file{position.hh} is generated for backward compatibility.
@item History:
Introduced in Bison 3.2.
@end itemize
@end deffn
@c ================================================== api.prefix
@deffn {Directive} {%define api.prefix} @{@var{prefix}@}
@@ -6001,27 +5984,6 @@ the @code{full} value was introduced in Bison 2.7
@c ================================================== api.stack.file
@deffn {Directive} {%define api.stack.file} @code{none}
@itemize @bullet
@item Language(s): C++
@item Purpose:
Disable the generation of the legacy file @file{stack.hh}.
@item Accepted Values: @code{none}
@item Default Value:
@code{none} if @code{api.location.file} is defined, otherwise a useless
@file{stack.hh} is generated for backward compatibility.
@item History:
Introduced in Bison 3.2.
@end itemize
@end deffn
@c ================================================== api.token.constructor
@deffn Directive {%define api.token.constructor}
@@ -10681,12 +10643,9 @@ extension of these two files follow the same rules as with regular C parsers
(@pxref{Invocation}).
@item position.hh
A useless legacy file. To get rid of it, use @samp{%define api.stack.file
none}, or define @code{api.location.file}.
@item stack.hh
A useless legacy file. To get rid of it, use @samp{%define
api.position.file none}, or define @code{api.location.file}.
@itemx stack.hh
Useless legacy files. To get rid of then, use @samp{%require "3.2"} or
newer.
@end table
All these files are documented using Doxygen; run @command{doxygen} for a