Beg pardon, wrong question.
Would you give me an example of a separate string id parser (like
ident?) used in a comma-separated-list parser? In short, I don't
know how to resolve the discrepancy in attributes.
Do you mean something like this?
#include
namespace ecgp {
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
template <typename Iterator>
struct ident
: qi::grammar
{
ident(): ident::base_type(start) {
using namespace qi;
start %= lexeme[('_' | alpha) >> *(digit | alpha | '_' | '-')];
}
qi::rule start;
};
template <typename Iterator>
struct idlist
: qi::grammarstd::string(), ascii::space_type>
{
ecgp::ident<Iterator> id;
idlist(): idlist::base_type(start) {
using namespace qi;
start %= id % ','; // don't use a sequence here
}
qi::rulestd::string(), ascii::space_type> start;
};
}
namespace qi = boost::spirit::qi;
int main()
{
ecgp::idliststd::string::const_iterator g;
std::string input("abc,def");
std::string::const_iterator begin = input.begin();
std::string::const_iterator end = input.end();
std::vectorstd::string v;
qi::phrase_parse(begin, end, g, qi::ascii::space, v);
BOOST_ASSERT(v.size() == 2 && v[0] == "abc" && v[1] == "def");
return 0;
}
Regards Hartmut
---------------
Meet me at BoostCon
www.boostcon.com