Spirit X3中序列的位置注释

时间:2019-01-02 21:14:41

标签: boost-spirit-x3

什么是为返回序列的规则添加位置注释的好形式?

假设我的语法规则如下:

const auto array_def = '[' >> *int_ >> ']';
合成类型std::vector< int >的属性的

,我考虑过通过将向量序列封装为虚构类型来添加位置注释:

struct array_t { std::vector< int > value; };

并根据X3教程添加位置注释:

struct array_t : x3::position_tagged { std::vector< int > value; };

等。不幸的是,这无法像Boost.Spirit X3 parser "no type named type in(...)"中所述那样工作,我在其中看到折叠的单个元素序列已在Spirit中被拒绝。

可能剩下的就是走以下路线:

struct array_t : x3::position_tagged, std::vector< int > { };

这可以工作(实际上是可行的),但与数十年来的良好实践相矛盾,后者说不继承std类型。什么是好的X3形式?

0 个答案:

没有答案