|
Boost Users : |
From: Micha³ Nowotka (mmmnow_at_[hidden])
Date: 2007-12-28 07:54:15
Hello,
I'm currently writing simple server implementation and want to parse
GET request header and load passed attributes. I though with boost
spirit this will be very simple task but i got some errors I can't
understand. My function (these are my first lines of code using
spirit):
bool GET_parse(std::string &str, std::vector<std::string> &keys,
std::vector<std::string> &values)
{
using namespace boost::spirit;
uint_parser<unsigned,10,1,1> my_digit;
rule<> request,method,path,version_id,stri,web_sign,attribs;
request = method >> path >> version_id;
method = as_lower_d["get"];//method = str_p["GET"];
version_id = str_p("HTTP") >> ch_p('/') >> my_digit >> ch_p('.')
>> my_digit;
path = ch_p('/') >> !(stri >> *(ch_p('/') >> stri) >> !(ch_p('?')
>> attribs));
stri = +(web_sign);
web_sign = alnum_p | ch_p('_') | ch_p('_') | ch_p('.');
attribs = *((+alnum_p)[push_back_a(keys)] >> ch_p('=') >>
(+alnum_p)[push_back_a(values)] >> !ch_p('&'));
return parse(str.c_str(), request, space_p).full;
}
and output (for me totally unreadable):
In member function 'typename boost::spirit::parser_result<DerivedT,
ScannerT>::type boost::spirit::impl::rule_base<DerivedT, EmbedT, T0,
T1, T2>::parse_main(const ScannerT&) const [with ScannerT =
boost::spirit::scanner<const char*,
boost::spirit::scanner_policies<boost::spirit::skipper_iteration_policy<boost::spirit::iteration_policy>,
boost::spirit::match_policy, boost::spirit::action_policy> >, DerivedT
= boost::spirit::rule<boost::spirit::nil_t, boost::spirit::nil_t,
boost::spirit::nil_t>, EmbedT = const
boost::spirit::rule<boost::spirit::nil_t, boost::spirit::nil_t,
boost::spirit::nil_t>&, T0 = boost::spirit::nil_t, T1 =
boost::spirit::nil_t, T2 = boost::spirit::nil_t]':
/usr/include/boost/spirit/core/non_terminal/impl/rule.ipp:171:
instantiated from 'typename boost::spirit::parser_result<DerivedT,
ScannerT>::type boost::spirit::impl::rule_base<DerivedT, EmbedT, T0,
T1, T2>::parse(const ScannerT&) const [with ScannerT =
boost::spirit::scanner<const char*,
boost::spirit::scanner_policies<boost::spirit::skipper_iteration_policy<boost::spirit::iteration_policy>,
boost::spirit::match_policy, boost::spirit::action_policy> >, DerivedT
= boost::spirit::rule<boost::spirit::nil_t, boost::spirit::nil_t,
boost::spirit::nil_t>, EmbedT = const
boost::spirit::rule<boost::spirit::nil_t, boost::spirit::nil_t,
boost::spirit::nil_t>&, T0 = boost::spirit::nil_t, T1 =
boost::spirit::nil_t, T2 = boost::spirit::nil_t]'
/usr/include/boost/spirit/core/scanner/impl/skipper.ipp:131:
instantiated from 'static boost::spirit::parse_info<IteratorT>
boost::spirit::impl::phrase_parser<boost::spirit::space_parser>::parse(const
IteratorT&, const IteratorT&, const ParserT&, const
boost::spirit::space_parser&) [with IteratorT = const char*, ParserT =
boost::spirit::rule<boost::spirit::nil_t, boost::spirit::nil_t,
boost::spirit::nil_t>]'
/usr/include/boost/spirit/core/scanner/impl/skipper.ipp:153:
instantiated from 'boost::spirit::parse_info<IteratorT>
boost::spirit::parse(const IteratorT&, const IteratorT&, const
boost::spirit::parser<DerivedT>&, const boost::spirit::parser<SkipT>&)
[with IteratorT = const char*, ParserT =
boost::spirit::rule<boost::spirit::nil_t, boost::spirit::nil_t,
boost::spirit::nil_t>, SkipT = boost::spirit::space_parser]'
/usr/include/boost/spirit/core/scanner/impl/skipper.ipp:171:
instantiated from 'boost::spirit::parse_info<const CharT*>
boost::spirit::parse(const CharT*, const
boost::spirit::parser<DerivedT>&, const boost::spirit::parser<SkipT>&)
[with CharT = char, ParserT =
boost::spirit::rule<boost::spirit::nil_t, boost::spirit::nil_t,
boost::spirit::nil_t>, SkipT = boost::spirit::space_parser]'
serwer_www.cpp:52: instantiated from here
/usr/include/boost/spirit/core/non_terminal/impl/rule.ipp:189: error:
no matching function for call to
'boost::spirit::impl::abstract_parser<boost::spirit::scanner<const
char*, boost::spirit::scanner_policies<boost::spirit::iteration_policy,
boost::spirit::match_policy, boost::spirit::action_policy> >,
boost::spirit::nil_t>::do_parse_virtual(const
boost::spirit::scanner<const char*,
boost::spirit::scanner_policies<boost::spirit::skipper_iteration_policy<boost::spirit::iteration_policy>,
boost::spirit::match_policy, boost::spirit::action_policy> >&)'
/usr/include/boost/spirit/core/non_terminal/impl/rule.ipp:213: note:
candidates are: typename boost::spirit::match_result<ScannerT,
AttrT>::type boost::spirit::impl::abstract_parser<ScannerT,
AttrT>::do_parse_virtual(const ScannerT&) const [with ScannerT =
boost::spirit::scanner<const char*,
boost::spirit::scanner_policies<boost::spirit::iteration_policy,
boost::spirit::match_policy, boost::spirit::action_policy> >, AttrT =
boost::spirit::nil_t]
can you tell me where my code is wrong and why?
-- Cheers, Micha³ Nowotka
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