$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [spirit] first steps
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2010-02-18 13:29:01
> > Please provide us with a minimal, self-contained piece of code we can
> > compile. We have no crystal ball to see what you're doing...
> 
> Sorry, I was sure it's so basic, that there's even no need for real
> source-code.
Sure it is, but I wanted to see which placeholder do you use, and what
includes you have.
> Here it is:
> 
> #include <string>
> #include <boost/spirit/include/qi.hpp>
> #include <boost/spirit/include/phoenix_core.hpp>
> #include <boost/spirit/include/phoenix_operator.hpp>
> 
> namespace qi = boost::spirit::qi;
> namespace ascii = boost::spirit::ascii;
> namespace phoenix = boost::phoenix;
> int main()
> {
> 	using qi::int_;
> 	using qi::string;
> 	using qi::_1;
> 	using ascii::space;
> 	using phoenix::ref;
> 
> 	int i1;
> 	std::string s1;
> 	std::string source;
> 	std::string::iterator first = source.begin(), last =
> source.end();
> // compiles well:
> 	qi::phrase_parse(first, last,
> 	(
> 		int_[ref(i1) = _1]
> 	)
> 	,
> 	space);
> 
> // doesn't compile:
> 	qi::phrase_parse(first, last,
> 	(
> 		string[ref(s1) = _1]
> 	)
> 	,
> 	space);
> 
> }
qi::string is not a valid parser primitive. What would you expect it to
match anyway? You'll have to be a bit more specific about what kind of
string you need to parse, for instance:
    '"' >> ~+char_('"') >> '"'
(i.e. a quote followed by at least one character which is not a quote
followed by a quote).
Regards Hartmut
---------------
Meet me at BoostCon
www.boostcon.com