2013/12/12 Francois Mauger <mauger@lpccaen.in2p3.fr>
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::rule<std::string::iterator> key_rule   = +(char_ - '=');
    boost::spirit::qi::rule<std::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<std::string::iterator, std::vector<char>()> key_rule;

And I'd suggest using attr propagation instead of the explicit semantic action if possible.


HTH