diff --git a/data/bison.m4 b/data/bison.m4 index 87ad0ca1..6dde067d 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -65,14 +65,16 @@ version 2.2 of Bison.])]) ## Output. ## ## -------- ## -# b4_output_begin(FILE) -# --------------------- +# b4_output_begin(FILE1, FILE2) +# ----------------------------- # Enable output, i.e., send to diversion 0, expand after "#", and # generate the tag to output into FILE. Must be followed by EOL. +# FILE is FILE1 concatenated to FILE2. FILE2 can be empty, or be +# absolute: do the right thing. m4_define([b4_output_begin], [m4_changecom() m4_divert_push(0)dnl -@output(m4_unquote([$1])@)@dnl +@output(m4_unquote([$1])@,m4_unquote([$2])@)@dnl ]) diff --git a/data/location.cc b/data/location.cc index 7ebf2f40..9c21cecd 100644 --- a/data/location.cc +++ b/data/location.cc @@ -305,7 +305,7 @@ m4_define([b4_location_define], m4_ifdef([b4_position_file], [[ -]b4_output_begin([b4_dir_prefix[]b4_position_file])[ +]b4_output_begin([b4_dir_prefix], [b4_position_file])[ // Starting with Bison 3.2, this file is useless: the structure it // used to define is now defined in "]b4_location_file[". // @@ -323,7 +323,7 @@ m4_ifdef([b4_position_file], [[ m4_ifdef([b4_location_file], [[ -]b4_output_begin([b4_dir_prefix[]b4_location_file])[ +]b4_output_begin([b4_dir_prefix], [b4_location_file])[ ]b4_copyright([Locations for Bison parsers in C++])[ /** diff --git a/data/stack.hh b/data/stack.hh index 1946cc48..a8b13b04 100644 --- a/data/stack.hh +++ b/data/stack.hh @@ -140,7 +140,7 @@ m4_define([b4_stack_define], m4_ifdef([b4_stack_file], -[b4_output_begin([b4_dir_prefix[]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. // diff --git a/src/scan-skel.l b/src/scan-skel.l index 096a07ae..63a6dc32 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -29,8 +29,9 @@ #define FLEX_PREFIX(Id) skel_ ## Id #include -#include #include +#include +#include #include #include @@ -236,14 +237,14 @@ at_complain (int argc, char *argv[], char **out_namep, int *out_linenop) static void at_output (int argc, char *argv[], char **out_namep, int *out_linenop) { - if (2 < argc) + if (3 < argc) fail_for_at_directive_too_many_args (argv[0]); if (*out_namep) { free (*out_namep); xfclose (yyout); } - *out_namep = xstrdup (argv[1]); + *out_namep = xpath_join (argv[1], 2 < argc ? argv[2] : NULL); output_file_name_check (out_namep, true); /* If there were errors, do not generate the output. */ yyout = xfopen (complaint_status ? "/dev/null" : *out_namep, "w"); diff --git a/tests/output.at b/tests/output.at index 3ee79df7..2c2cd9b8 100644 --- a/tests/output.at +++ b/tests/output.at @@ -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]) diff --git a/tests/skeletons.at b/tests/skeletons.at index 5e99b340..8c180564 100644 --- a/tests/skeletons.at +++ b/tests/skeletons.at @@ -306,7 +306,7 @@ use strict; my $M4 = "m4"; my $DNL = "d"."nl"; print "${M4}_divert_push(0)$DNL\n"; -print '@output(@,@)', "\n"; +print '@output(@,@,@)', "\n"; (print "garbage"x10, "\n") for (1..1000); print "${M4}_divert_pop(0)\n"; ]])