Boost logo

Boost Users :

Subject: [Boost-users] [spirit] what's wrong with my parser ?
From: Kamil Zubair (kamilzubair_at_[hidden])
Date: 2010-06-02 11:16:01


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<float, boost::optional<float> > range_val;

    rule<string::const_iterator, range_val(), locals<float, boost::optional<float> > > range_value;
    rule<string::const_iterator> valid_line;
    range_value = (float_[_a = _1] | ("[" >> *space >> float_[_a = _1] >> ',' >> float_[_b = _1] >> *space >> "]"))[_val = boost::phoenix::bind(make_pair<float, boost::optional<float> >, _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<char,std::char_traits<char>,std::allocator<char>>,
1>            Expr=boost::proto::exprns_::expr<boost::proto::tag::shift_left,boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,boost::proto::argsns_::term<const char (&)[9]>,0>,boost::spirit::qi::rule<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>>,range_val (void),boost::spirit::locals<float,boost::optional<float>>> &>,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 =<boost::proto::exprns_::expr<Tag,Args,Arity>>(const Expr &)' being compiled
1>        with
1>        [
1>            Iterator=std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>>,
1>            Tag=boost::proto::tag::shift_left,
1>            Args=boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,boost::proto::argsns_::term<const char (&)[9]>,0>,boost::spirit::qi::rule<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>>,range_val (void),boost::spirit::locals<float,boost::optional<float>>> &>,
1>            Arity=2,
1>            Expr=boost::proto::exprns_::expr<boost::proto::tag::shift_left,boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,boost::proto::argsns_::term<const char (&)[9]>,0>,boost::spirit::qi::rule<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>>,range_val (void),boost::spirit::locals<float,boost::optional<float>>> &>,2>
1>        ]

can someone point out what's wrong with my parser ?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net