i want to parse the following line with boost::spirit
0 "a" "b" "c"
I've created my rules like this:
qi::rule<std::string::const_iterator, std::string()> escaped_ = qi::char_('"') >> *(qi::char_ - qi::char_('"')) >> qi::char_('"');
int id;
std::string v1,v2,v3;
qi::phrase_parse(bein, end, (qi::int_ >> escaped_ >> escaped_ >> escaped_ >> qi::eol), id, v1, v2, v3);
But the parsing failed and i don't know why. Hopefully someone can help.
phrase_parse
takes (it, it, parser, skipper[, attribute...]). You forgot to pass a skipper:I suggest
qi::blank
there because your grammar treatseol
as significant (skipping it would never match).Final note, you like didn't want to parse
"
as part of the resulting values (changeqi::char_('"')
intoqi::lit('"')
or, equivalently'"'
if possible).Demo
Live On Coliru
Prints