Boost logo

Boost Users :

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


I forgot to mention that this code compile fine with boost 1.41. I actually find out if I change the line:
rule<string::const_iterator, range_val(), locals<float, boost::optional<float> > > range_value;
to
rule<string::const_iterator, locals<float, boost::optional<float> > > range_value;
the errors dissapear. Is there changes on how to specify attributes of rule between boost 1.41 and boost 1.43 ?

--- Pada Rab, 2/6/10, Hartmut Kaiser <hartmut.kaiser_at_[hidden]> menulis:

Dari: Hartmut Kaiser <hartmut.kaiser_at_[hidden]>
Judul: Re: [Boost-users] [spirit] what's wrong with my parser ?
Kepada: boost-users_at_[hidden]
Tanggal: Rabu, 2 Juni, 2010, 11:29 AM

> 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<c
> har>,std::allocator<char>>,
> 1>            Expr=boost::proto::exprns_::expr<boost::proto::tag::shift_le
> ft,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::c
> har_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

If you read the comment above this line (rule.hpp, line 176):

    // Report invalid expression error as early as possible.
    // If you got an error_invalid_expression error message here,
    // then the expression (expr) is not a valid spirit qi expression.

explaining a possible cause of this compile time assertion. Most likely you
forgot to include the appropriate header file for one or more of the used
parser constructs. See the docs of the parsers you are using to see what
header you need to include for them.

Regards Hartmut

---------------
Meet me at BoostCon
www.boostcon.com

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users



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