|
Boost Users : |
Subject: Re: [Boost-users] [spirit] what's wrong with my parser ?
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2010-06-02 12:29:37
> 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 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