Spirit X3没有匹配功能可以调用' move_to'

时间:2016-03-16 00:39:18

标签: c++ boost boost-spirit-x3

为什么这不编译? (评论r3将编译,但我希望在规则中使用分号)

#include <boost/spirit/home/x3.hpp>
#include <boost/fusion/include/adapt_struct.hpp>

#include <string>
#include <vector>

struct v
{
    std::string value;
};

BOOST_FUSION_ADAPT_STRUCT
(
    v,
    (std::string, value)
)

using namespace boost::spirit::x3;

auto r1 = rule<struct s1, std::string>{} = lexeme[+alpha];

auto r2 = rule<struct s2, v>{} = r1;

using ast = std::vector<v>;

auto r3 = rule<struct s3, ast>{} = *(r2 >> ';');
//auto r3 = rule<struct s3, ast>{} = *r2;

int main()
{
    std::string script("a;");
    auto begin = script.begin();
    auto   end = script.end();

    ast a;

    phrase_parse(begin, end, r3, space, a);

    return a.size();
}

1 个答案:

答案 0 :(得分:5)

正如@jv_建议的那样,我已经下载了develop分支机构。之后,代码无需任何更改即可运行。