c++: add support for api.position.file and api.location.file

* data/location.cc: Sort includes.
(b4_position_file, b4_location_file): New.
When there's a file for locations but not for positions, include the
definition of position in the location file.
* data/lalr1.cc (b4_shared_declarations): Include the
position/location file when it exists.
Otherwise, define the class.
* data/glr.cc: Likewise.
* tests/input.at (%define file variables): Check them.
* tests/output.at (C++ output): Check various cases with
api.position.file and api.location.file.
This commit is contained in:
Akim Demaille
2018-09-29 10:32:32 +02:00
parent b122a71c83
commit 667588ee8a
6 changed files with 89 additions and 29 deletions

View File

@@ -165,8 +165,10 @@ m4_define([b4_shared_declarations],
]b4_cxx_portability[
]m4_ifdef([b4_stack_file],
[[# include "]b4_stack_file["]])[
]b4_defines_if([[
]b4_bison_locations_if([[# include "location.hh"]])])[
]m4_ifdef([b4_position_file],
[[# include "]b4_position_file["]])[
]m4_ifdef([b4_location_file],
[[# include "]b4_location_file["]])[
]b4_variant_if([b4_variant_includes])[
]b4_attribute_define[
@@ -176,10 +178,11 @@ m4_define([b4_shared_declarations],
]b4_namespace_open[
]m4_ifdef([b4_stack_file], [], [b4_stack_define])[
]b4_defines_if([],
[b4_bison_locations_if([b4_position_define
b4_location_define])])[
]m4_ifndef([b4_stack_file], [b4_stack_define])[
]b4_bison_locations_if([m4_ifndef([b4_location_file],
[m4_ifndef([b4_position_file], [b4_position_define
])[]b4_location_define])])[
]b4_variant_if([b4_variant_define])[