The standard version of Bison makes it quite simple to redefine the location type by making sure the following four fields are available:
customsourcelocation.h
struct CustomSourceLocation
{
int first_line;
int first_column;
int last_line;
int last_column;
};
parser.y
...
%define api.location.type {CustomSourceLocation}
...
%code requires {
#include "customsourcelocation.h"
}
...
However the C++ version of location seems more advanced as the structure making up the location type is made up of multiple position
objects as well.
Can anyone provide a basic example of redefining the location type for a C++ Bison parser, so that the location data object is independent of Bison and therefore can be included from any file without the need to also include any of Bison's generated code?
Thanks in advance.
Thanks to rici for pointing out the answer. A location.hh file will be generated when using the %locations option, which can be modified and included as fit.