Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:39:35+00:00 2026-06-03T05:39:35+00:00

I have to use boost::spirit for parsing, and I want use phrase_parse function :

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:39:37+00:00Added an answer on June 3, 2026 at 5:39 am

    The simplest answer is

    qi::phrase_parse(str.begin(), str.end(), grammar, ascii::blank); 
    

    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_type for a Grammar that should only accept qi::blank).

    The sample handles arbitrary skippers too.

    Other hints

    Spirit has several directives that influence the use of skippers:

    • qi::lexeme

      will parse the sub-expression regardless of skipper (useful for e.g. string literals in a grammar)

    • qi::raw

      will return the raw source iterator range, meaning that skipped input will be included in the result

    • qi::no_skip, qi::skip

      can 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

    • Parsing Skippers and Skipping Parsers

    Generic sample

    #include <boost/spirit/include/qi.hpp>
    
    namespace qi = boost::spirit::qi;
    
    template <typename It, typename Skipper>
        struct parser : qi::grammar<It, Skipper>
    {
        parser() : parser::base_type(start)
        {
            start = *qi::int_;
        }
    
      private:
        qi::rule<It, Skipper> start;
    };
    
    template <typename C, typename Skipper>
        void doParse(const C& input, const Skipper& skipper)
    {
        auto f(std::begin(input)), l(std::end(input));
    
        parser<decltype(f), Skipper> p;
        bool ok = qi::phrase_parse(f,l,p,skipper);
    
        if (ok)   
            std::cout << "parse success\n";
    }
    
    int main()
    {
        const std::string input = "1 2 3 4";
        doParse(input, qi::blank);
        doParse(input, qi::space);
        doParse(input, ~qi::char_("0-9"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have gcc 4.4.5 and the latest boost library. I want to use boost
I can't use boost:hash because I have to stick with C and can't use
Assume that I have a boost::function of with an arbitrary signature called type CallbackType
I want to use Boost C++ in a Windows 8 Metro app and I
I am starting a new c++ project and I want to use Boost.Build /
I use valgrind to debug my application. I have two machines where I want
I have tried to use Boost and had a segv after 3000 allocations of
I have a program where I use boost::threads for multi threading. Unfortunately drd (
I want to use boost::bind (I'm not sure if it is really the right
Let's say I have time_t and tm structure. I can't use Boost but MFC.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.