What is considered good form for adding position annotations for rules that return sequences?
Assuming I have a rule in my grammar of the form:
const auto array_def = '[' >> *int_ >> ']';
that synthesizes an attribute of type std::vector< int >
, I thought about adding position annotation via an encapsulation of the vector sequence into a made-up type:
struct array_t { std::vector< int > value; };
and add position annotation as per the X3 tutorials:
struct array_t : x3::position_tagged { std::vector< int > value; };
, etc. Unfortunately, this does not work as explained in Boost.Spirit X3 parser "no type named type in(...)" where I see that collapsing single element sequences has been rejected in Spirit.
What's left is perhaps to go the route of:
struct array_t : x3::position_tagged, std::vector< int > { };
which would work (actually, works) but it contradicts decades of good practice that says don't inherit std
types. What is good X3 form here?