Boost logo

Boost :

Subject: Re: [boost] [metaparse] review
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2015-06-04 02:07:52


On Jun 4, 2015, at 12:56 AM, Abel Sinkovics <abel_at_[hidden]> wrote:

>>>> I gave up here and made the separator mandatory. Again, this is probably not a flaw in the design, but the documentation should describe what kinds of grammars will work, and perhaps give pointers to other resources about disambiguating grammars. Probably there is a different construct which would help here.
>>> I'm not sure what error you ended up with in this case.
>> This is also commented in the gist.
> According to gist it looks like using last_of is fine while using sequence is not. And they return different things: last_of returns the result of stmt, sequence returns a container with [optional semicolon, result of stmt] as elements. (and the code processing the result needs to expect the right thing)

Yeah, I was accounting for that. I got an error about trying to evaluate void::type, so maybe the problem was just that the default here also needs to return a self-recursive type:

template<typename Parser, typename Default = void>
using opt = one_of<Parser, return_<Default>>;

It might be good to include opt<> (optional) in the library, or to have a short cookbook of common patterns like this, since it is not always obvious if one is doing the right thing.

Thanks for a powerful library!

Cheers,
Gordon


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk