Quantcast

Lazy Spirit Generators?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Lazy Spirit Generators?

Boost - Dev mailing list
Hi,

In a hobby project, I am using Spirit Karma generators. As far as I have
understood Spirit Karma, it is not designed to work lazily in the
iterator based interface. It takes an output iterator and writes to it
until it has finished.

What I am thinking of is a kind of generating range. E.g.:

for(auto& char:
         generator_range(double_ << " + " << double_ << "i",
                         context, c.real(), c.imag())) {
    // do whatever with the single characters returned by the generator
}

Is there something like that, which I simply have not found?

Christof

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lazy Spirit Generators?

Boost - Dev mailing list

> In a hobby project, I am using Spirit Karma generators. As far as I have
> understood Spirit Karma, it is not designed to work lazily in the
> iterator based interface. It takes an output iterator and writes to it
> until it has finished.
>
> What I am thinking of is a kind of generating range. E.g.:
>
> for(auto& char:
>          generator_range(double_ << " + " << double_ << "i",
>                          context, c.real(), c.imag())) {
>     // do whatever with the single characters returned by the generator
> }
>
> Is there something like that, which I simply have not found?

The short answer is 'no'. Once we have co_await/co_yield and coroutines
support in the language it could be easily built, though.

Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lazy Spirit Generators?

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On Feb 13, 2017 10:25 AM, "Christof Donat via Boost" <[hidden email]>
wrote:

In a hobby project, I am using Spirit Karma generators. As far as I have
understood Spirit Karma, it is not designed to work lazily in the iterator
based interface. It takes an output iterator and writes to it until it has
finished.

What I am thinking of is a kind of generating range. E.g.:

for(auto& char:
        generator_range(double_ << " + " << double_ << "i",
                        context, c.real(), c.imag())) {
   // do whatever with the single characters returned by the generator
}

Is there something like that, which I simply have not found?


You should be able to build that with Boost.Coroutine. Launch the Karma
generator in a pull_type coroutine, which accepts a (corresponding)
push_type coroutine as its argument. A push_tyoe coroutine can be used as
an output iterator. Pass that iterator to Karma, and then lazily retrieve
characters from the pull_type coroutine.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Loading...