Previous: C++ location, Up: C++ Location Values [Contents][Index]
Instead of using the built-in types you may use the %define
variable
api.location.type
to specify your own type:
%define api.location.type {LocationType}
The requirements over your LocationType are:
@$
in a reduction, the
parser basically runs
@$.begin = @1.begin; @$.end = @N.end; // The location of last right-hand side symbol.
so there must be copyable begin
and end
members;
In programs with several C++ parsers, you may also use the %define
variable api.location.type
to share a common set of built-in
definitions for position
and location
. For instance, one
parser master/parser.yy might use:
%defines %locations %define api.namespace {master::}
to generate the master/position.hh and master/location.hh files, reused by other parsers as follows:
%define api.location.type {master::location} %code requires { #include <master/location.hh> }