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

@@ -61,6 +61,16 @@ This special exception was added by the Free Software Foundation in
version 2.2 of Bison.])])
# b4_required_version_if(VERSION, IF_NEWER, IF_OLDER)
# ---------------------------------------------------
# If the version %require'd by the user is VERSION (or newer) expand
# IF_NEWER, otherwise IF_OLDER. VERSION should be an integer, e.g.,
# 302 for 3.2.
m4_define([b4_required_version_if],
[m4_if(m4_eval($1 <= b4_required_version),
[1], [$2], [$3])])
## -------- ##
## Output. ##
## -------- ##

View File

@@ -22,12 +22,8 @@ m4_pushdef([b4_copyright_years],
# b4_position_file
# ----------------
# Name of the file containing the position class, if we want this file.
b4_percent_define_ifdef([[api.position.file]],
[b4_percent_define_check_values([[[[api.position.file]],
[[none]]]])],
[b4_defines_if([b4_percent_define_ifdef([[api.location.file]],
[],
[m4_define([b4_position_file], [position.hh])])])])
b4_defines_if([b4_required_version_if([302], [],
[m4_define([b4_position_file], [position.hh])])])])
# b4_location_file
@@ -330,12 +326,9 @@ m4_ifdef([b4_position_file], [[
// used to define is now defined in "]b4_location_file[".
//
// To get rid of this file:
// 1. add '%define api.position.file none'
// or '%define api.location.file none'
// or '%define api.location.file "my-loc.hh"' to your grammar file
// 2. add 'require "3.2"' to your grammar file
// 3. remove references to this file from your build system
// 4. if you used to include it, include "]b4_location_file[" instead.
// 1. add 'require "3.2"' (or newer) to your grammar file
// 2. remove references to this file from your build system
// 3. if you used to include it, include "]b4_location_file[" instead.
#include ]b4_location_include[
]b4_output_end[

View File

@@ -19,12 +19,8 @@
# b4_stack_file
# -------------
# Name of the file containing the stack class, if we want this file.
b4_percent_define_ifdef([[api.stack.file]],
[b4_percent_define_check_values([[[[api.stack.file]],
[[none]]]])],
[b4_defines_if([b4_percent_define_ifdef([[api.location.file]],
[],
[m4_define([b4_stack_file], [stack.hh])])])])
b4_defines_if([b4_required_version_if([302], [],
[m4_define([b4_stack_file], [stack.hh])])])
# b4_stack_define
@@ -138,17 +134,13 @@ m4_define([b4_stack_define],
};
]])
m4_ifdef([b4_stack_file],
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
// Starting with Bison 3.2, this file is useless: the structure it
// used to define is now defined with the parser itself.
//
// To get rid of this file:
// 1. add '%define api.stack.file none'
// or '%define api.location.file none'
// or '%define api.location.file "my-loc.hh"' to your grammar file
// 2. add 'require "3.2"' to your grammar file
// 3. remove references to this file from your build system.
// 1. add 'require "3.2"' (or newer) to your grammar file
// 2. remove references to this file from your build system.
]b4_output_end[
]])