考虑以下代码:
namespace qi = boost::spirit::qi;
typedef qi::rule<
std::string::const_iterator
> rule_type;
rule_type value_rule = +qi::char_ - ( '[' | qi::eoi );
std::string input( "Hello World" );
std::string value0, value1;
bool b0 = qi::parse( input.begin( ),
input.end( ),
value_rule,
value0 );
bool b1 = qi::parse( input.begin( ),
input.end( ),
+qi::char_ - ( '[' | qi::eoi ),
value1 );
结果:
b0 = true
b1 = true
value0 = ""
value1 = "Hello World"
我很困惑为什么结果不同。获得相同结果的 qi::rule 类型的正确定义是什么?