mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
c++: provide control over the stack.hh file name
It was not a good idea to generate the file stack.hh. It never was. But now we have to deal with backward compatibility: if we stop generating it, the build system of some build system will probably break. So offer the user a means to (i) decide what the name of the output file should be, and (ii) not generate this file at all (its content will be inline where the parser is defined). * data/lalr1.cc (b4_percent_define_check_file_complain) (b4_percent_define_check_file): New. * data/stack.hh: Generate the file only if api.stack.file is not empty. In that case, use it as file name. * data/lalr1.cc: Adjust to include the right file, or to include the definition of stack. * tests/calc.at, tests/output.at: Exercise api.stack.file.
This commit is contained in:
@@ -694,6 +694,9 @@ AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %
|
||||
AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||
|
||||
AT_CHECK_CALC_LALR1_CC([%locations %define api.stack.file "my-stack.hh"])
|
||||
AT_CHECK_CALC_LALR1_CC([%locations %defines %define api.stack.file none])
|
||||
AT_CHECK_CALC_LALR1_CC([%defines %locations %define api.stack.file "my-stack.hh"])
|
||||
|
||||
|
||||
# --------------------------- #
|
||||
|
||||
@@ -1649,6 +1649,28 @@ input.y:1.9-21: accepted value: 'both'
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
|
||||
## ------------------------ ##
|
||||
## %define file variables. ##
|
||||
## ------------------------ ##
|
||||
|
||||
AT_SETUP([["%define" file variables]])
|
||||
|
||||
AT_DATA([[input.y]],
|
||||
[[%skeleton "lalr1.cc"
|
||||
%define api.stack.file bogus
|
||||
%%
|
||||
start: %empty;
|
||||
]])
|
||||
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
|
||||
[[input.y:2.9-22: error: %define variable 'api.stack.file' requires 'none' or '"..."' values
|
||||
%define api.stack.file bogus
|
||||
^^^^^^^^^^^^^^
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
## -------------------------------- ##
|
||||
## %define backward compatibility. ##
|
||||
## -------------------------------- ##
|
||||
|
||||
@@ -145,6 +145,9 @@ AT_CHECK([grep 'include .subdir/' $1.cc], 1, [])
|
||||
AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
|
||||
])
|
||||
|
||||
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc"], [],
|
||||
[foo.tab.cc])
|
||||
|
||||
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [],
|
||||
[foo.output foo.tab.cc])
|
||||
|
||||
@@ -176,6 +179,22 @@ AT_CHECK_OUTPUT([gram_dir/foo.yy],
|
||||
[],
|
||||
[output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/location.hh output_dir/position.hh output_dir/stack.hh])
|
||||
|
||||
# api.stack.file.
|
||||
AT_CHECK_OUTPUT([foo.yy],
|
||||
[%skeleton "lalr1.cc" %define api.stack.file "foo.sta.hh"],
|
||||
[],
|
||||
[foo.sta.hh foo.tab.cc])
|
||||
|
||||
AT_CHECK_OUTPUT([foo.yy],
|
||||
[%skeleton "lalr1.cc" %defines %define api.stack.file none],
|
||||
[],
|
||||
[foo.tab.cc foo.tab.hh])
|
||||
|
||||
AT_CHECK_OUTPUT([gram_dir/foo.yy],
|
||||
[%skeleton "lalr1.cc" %verbose %defines %define api.stack.file "foo.sta.hh" %file-prefix "output_dir/foo"],
|
||||
[],
|
||||
[output_dir/foo.output output_dir/foo.sta.hh output_dir/foo.tab.cc output_dir/foo.tab.hh])
|
||||
|
||||
|
||||
# AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,
|
||||
# [EXIT-STATUS])
|
||||
|
||||
Reference in New Issue
Block a user