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::vectorstd::string &keys,
std::vectorstd::string &values)
{
using namespace boost::spirit;
uint_parser 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::type boost::spirit::impl::rule_base::parse_main(const ScannerT&) const [with ScannerT =
boost::spirit::scannerboost::spirit::iteration_policy,
boost::spirit::match_policy, boost::spirit::action_policy> >, DerivedT
= boost::spirit::rule, EmbedT = const
boost::spirit::rule&, 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::type boost::spirit::impl::rule_base::parse(const ScannerT&) const [with ScannerT =
boost::spirit::scannerboost::spirit::iteration_policy,
boost::spirit::match_policy, boost::spirit::action_policy> >, DerivedT
= boost::spirit::rule, EmbedT = const
boost::spirit::rule&, 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_parserboost::spirit::space_parser::parse(const
IteratorT&, const IteratorT&, const ParserT&, const
boost::spirit::space_parser&) [with IteratorT = const char*, ParserT =
boost::spirit::rule]'
/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, SkipT = boost::spirit::space_parser]'
/usr/include/boost/spirit/core/scanner/impl/skipper.ipp:171:
instantiated from 'boost::spirit::parse_info
boost::spirit::parse(const CharT*, const
boost::spirit::parser<DerivedT>&, const boost::spirit::parser<SkipT>&)
[with CharT = char, ParserT =
boost::spirit::rule, 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::nil_t>::do_parse_virtual(const
boost::spirit::scannerboost::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::type boost::spirit::impl::abstract_parser::do_parse_virtual(const ScannerT&) const [with ScannerT =
boost::spirit::scanner >, AttrT =
boost::spirit::nil_t]
can you tell me where my code is wrong and why?
--
Cheers,
Michał Nowotka