c++: support absolute api.location.file names

In the case a user wants to create location.hh elsewhere, it can be
helpful to define api.location.file to some possibly absolute path
such as -Dapi.location.file='"$(top_srcdir)/include/ast/location.hh"'.
Currently this does not work with `-o foo/parser.cc`, as we join foo/
and $(top_srcdir) together, the latter starting with slash.

We should not try to do that in m4, manipulating file names is quite
complex when you through Windows file name in.  Let m4 delegate this
to gnulib.

* src/scan-skel.l (at_output): Accept up to two arguments.
* data/bison.m4 (b4_output): Adjust.
* tests/skeletons.at (Fatal errors but M4 continues producing output):
Adjust to keep the error.

* data/location.cc, data/stack.hh: Leave the concatenation to @output.
* tests/output.at: Exercise api.location.file with an absolute path.
This commit is contained in:
Akim Demaille
2018-10-06 13:03:59 +02:00
parent 57d69b04b2
commit 50b8d4ba5a
6 changed files with 22 additions and 13 deletions

View File

@@ -45,9 +45,13 @@ done
[$2[
%%
foo: %empty {};
]])[
]])
]AT_BISON_CHECK([$3 $1], [$5], [], [ignore])[
# There is not AT_DATA_UNQUOTED.
AT_CHECK([$PERL -pi -e 's{\$at_dir}'"{$at_group_dir}g" $1])
AT_BISON_CHECK([$3 $1], [$5], [], [ignore])[
# Ignore the files non-generated files
]AT_CHECK_FILES([$4], [$1])[
]$6[
@@ -206,8 +210,10 @@ AT_CHECK_OUTPUT([foo.yy],
[%skeleton "lalr1.cc" %defines %locations %define api.location.file "foo.loc.hh"],
[],
[foo.loc.hh foo.tab.cc foo.tab.hh])
# Absolute paths.
AT_CHECK_OUTPUT([foo.yy],
[%skeleton "lalr1.cc" %defines %define api.stack.file none %locations %define api.location.file "foo.loc.hh"],
[%skeleton "lalr1.cc" %defines %locations %define api.location.file "$at_dir/foo.loc.hh"],
[],
[foo.loc.hh foo.tab.cc foo.tab.hh])