I try to make parser for the following string:
"value = x" or
"value = [x1, x2]"
I also want to retrieve the value of x or x1 and x2.
My minimum code that will produce error is like this:
typedef pair range_val;
rule > range_value;
rulestring::const_iterator valid_line;
range_value = (float_[_a = _1] | ("[" >> *space >> float_[_a = _1] >> ',' >> float_[_b = _1] >> *space >> "]"))[_val = boost::phoenix::bind(make_pair, _a, _b)];
valid_line = "value = " << range_value;
I'm using vs 2008 with boost 1.43, the above code will produce this error:
1>f:\library\boost_1_41_0\boost\spirit\home\qi\nonterminal\rule.hpp(176) : error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter 1 from 'boost::mpl::failed ************(__thiscall boost::spirit::qi::rule<Iterator>::=::error_invalid_expression::* ***********)(Expr)' to 'boost::mpl::assert<false>::type'
1> with
1> [
1> Iterator=std::_String_const_iterator,
1> Expr=boost::proto::exprns_::expr,0>,boost::spirit::qi::rule,range_val (void),boost::spirit::locals> &>,2>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1> f:\project\experiment\spirit\spirit.cpp(82) : see reference to function template instantiation 'boost::spirit::qi::rule<Iterator> &boost::spirit::qi::rule<Iterator>::operator =>(const Expr &)' being compiled
1> with
1> [
1> Iterator=std::_String_const_iterator,
1> Tag=boost::proto::tag::shift_left,
1> Args=boost::proto::argsns_::list2,0>,boost::spirit::qi::rule,range_val (void),boost::spirit::locals> &>,
1> Arity=2,
1> Expr=boost::proto::exprns_::expr,0>,boost::spirit::qi::rule,range_val (void),boost::spirit::locals> &>,2>
1> ]
can someone point out what's wrong with my parser ?