一个简单的解析器,如Coliru上的。解析器-(+x3::alpha)
应该能够boost::optional<std::string>
像 Qi 那样传播类型的属性。但它不编译。
std::string const input = "abc";
boost::optional<std::string> attr;
if(x3::parse(boost::begin(input),boost::end(input),
-(+x3::alpha),
attr)) {
std::cout<<"match!"<<std::endl;
}
else {
std::cout<<"NOT match!"<<std::endl;
}