I have to use boost::spirit for parsing, and I want use phrase_parse function :
qi::phrase_parse(str.begin(), str.end(), grammar, ascii::space - qi::eol);
But the fourth term (ascii::space – qi::eol), isnt allowed by my compiler.
How can I use the skipper ascii::space WITHOUT skipping eol ?
The simplest answer is
Of course, it depends on your grammar too: if it expects a specific skipper class you might need to change that. See below for a generic way to handle that (although you could just specify
qi::blank_typefor a Grammar that should only acceptqi::blank).The sample handles arbitrary skippers too.
Other hints
Spirit has several directives that influence the use of skippers:
qi::lexemewill parse the sub-expression regardless of skipper (useful for e.g. string literals in a grammar)
qi::rawwill return the raw source iterator range, meaning that skipped input will be included in the result
qi::no_skip,qi::skipcan be used to explicitely change the type of skipper used for the subexpression
Recommended reading
The Boost Spirit site has a nice article about things like this
Generic sample