Я нашел решение, используя Semantic Actions
, вот код:
auto identity = [&](auto& ctx){x3::_val(ctx) = Eigen::Matrix3f::Identity();};
auto a = [&](auto& ctx){x3::_val(ctx)(0,0) = x3::_attr(ctx);};
auto b = [&](auto& ctx){x3::_val(ctx)(1,0) = x3::_attr(ctx);};
auto c = [&](auto& ctx){x3::_val(ctx)(0,1) = x3::_attr(ctx);};
auto d = [&](auto& ctx){x3::_val(ctx)(1,1) = x3::_attr(ctx);};
auto tx = [&](auto& ctx){x3::_val(ctx)(0,2) = x3::_attr(ctx);};
auto ty = [&](auto& ctx){x3::_val(ctx)(1,2) = x3::_attr(ctx);};
auto matRule = x3::rule<class MatId, Eigen::Matrix3f>() = x3::eps[identity] >> x3::no_case["matrix"]
>> "("
>> x3::float_[a]
>> ","
>> x3::float_[b]
>> ","
>> x3::float_[c]
>> ","
>> x3::float_[d]
>> ","
>> x3::float_[tx]
>> ","
>> x3::float_[ty]
>> ")";
std::string teststr = "matrix(2,3,4,5,6,7)";
Eigen::Matrix3f mat;
bool success = x3::phrase_parse(teststr.begin(), teststr.end(), matRule, x3::space, mat);
if (success) std::cout << mat << std::endl;