
2013/12/12 Francois Mauger
Dear Boosters,
The following code is one of my first attempts to use Spirit/Qi. For my education, I have tried 2 techniques to parse the simple "aaa=131;" string. The first one (Block A) compiles and seems to output the expected result. The second (B) does not compile with a huge massively templatized backtrace that I don't understand. What is the difference between using online rules and rule objects ? Is there a syntax error somewhere ? I'm afraid the documentation and example are rather terse about the syntax to be used here when coupling Qi and Phoenix...
[snip]
boost::spirit::qi::rulestd::string::iterator key_rule = +(char_ - '='); boost::spirit::qi::rulestd::string::iterator value_rule = lexeme[+(char_ - ';')];
bool r = phrase_parse( strbegin, s.end(), key_rule[boost::phoenix::ref(vkey) = boost::spirit::qi::_1 ] // <----HERE >> '=' >> *space >> value_rule[boost::phoenix::ref(vvalue) = boost::spirit::qi::_1 ], // <----HERE space );
The problem is (at least what I see): your key_rule/value_rule have no
attribute, so qi::_1 eventually evaluates to nothing (i.e. unused_type).
To give them attr, for example:
boost::spirit::qi::rule