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

  • Home
  • SEARCH
  • 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 7863605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:32:12+00:00 2026-06-02T23:32:12+00:00

Synopsis I would like to harness Boost Spirit’s stream parser API to parse an

  • 0

Synopsis

I would like to harness Boost Spirit’s stream parser API to parse an std::istream incrementally. However, I could not find a good example of how to use it with an iterator-based grammar. Conceptually, my goal is to parse an infinite stream of objects of type T.

Details

A grammar in Qi with an attribute of type T and skipper S typically has the form:

template <typename Iterator>
struct grammar : qi::grammar<Iterator, T(), S>;

How do I use such a grammar with the stream-based API? Specifically, my mental model for the stream API is that I can do something along the lines of:

// Callback invoked for each successfully parsed instance of T.
void f(T const& x)
{
}


// What iterator type?
grammar<???> parser;
skipper<???> skipper;

T x;

std::ifstream ifs("/path/to/file");
ifs.unsetf(std::ios::skipws)
while (! ifs.eof())
{
    ifs >> phrase_match(parser, skipper, x);
    if (ifs.good() || ifs.eof())
        f(x);
}

I am struggling with bringing together traditional grammars requiring iterators. How does that fit together with the stream API?

  • 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-02T23:32:14+00:00Added an answer on June 2, 2026 at 11:32 pm

    You’re missing the Spirit multi-pass iterator. Note, however, that parsing of the stream will not be done incrementally unless you go out of your way to make sure your grammar has minimal backtracking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to translate the following Unix 1 Liner to PowerShell. Synopsis of
Synopsis: Each User account has a UserProfile to hold extended info like phone numbers,
I would like to use jQuery to refresh a partial on a page, but
I would like to rename these files to not have the ending of (.processed2011*)
Question Synopsis Given a std::vector<T> , how can I create a view that exposes
I am new to Unix shell scripting and would like some help with writing
I have a mysql statement like this: mysql_query(INSERT INTO movies (comments, description, synopsis) VALUES
A = imread(filename, fmt) [X, map] = imread(...) The above is in the synopsis
Brief synopsis, this code works beautifully and does what it is supposed except with
Is there an OSS which can compress a text to a synopsis? My goal

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.