我有以下代码(floatDecs 和 intDecs 是符号解析器):
// Definition of the value parser:
typedef boost::variant<double,int64_t> value_type;
typedef boost::fusion::vector<std::string, value_type> dec_type;
rule<std::string::const_iterator, boost::variant<double,int64_t>(std::string)> value;
value = real_parser<double, strict_real_policies<double>>() [ boost::phoenix::bind(boost::lambda::unlambda(floatDecs.add), _r1, _1) ] |
int_parser<int64_t, 10>() [ boost::phoenix::bind(boost::lambda::unlambda(intDecs.add), _r1, _1) ];
rule<std::string::const_iterator, std::string()> ident;
ident %= lexeme[ alpha >> *alnum ];
rule<std::string::const_iterator, dec_type(), boost::spirit::qi::locals<std::string>, space_type> dec;
ident %= ident [_a = _1] >> lit('=') >> value(_a);
boost::spirit::qi::phrase_parse(testing.cbegin(), testing.cend(), dec, space);
问题:只有当我在每个规则中删除 space_type 并将最后一行替换为
boost::spirit::qi::parse(testing.cbegin(), testing.cend(), dec);