Boost logo

Boost Users :

Subject: Re: [Boost-users] Defining Statements with Proto
From: Eric Niebler (eric_at_[hidden])
Date: 2010-01-02 06:30:33


Apologies in advance for only the partial response. I'm pressed for time.

On 1/1/2010 6:29 AM, David A. Greene wrote:
> A few years ago, I asked how to define a grammar with
> Proto to match something like this:
>
> if_(expr) [
> stmt,
> stmt,
> ...
> ].else [
> stmt,
> stmt,
> ...
> ];
<snip>

>
> I didn't understand it then and I don't now. :) However, it seems to
> be obsolete since BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE doesn't
> seem to exist anymore (it's not documented, anyway).

It exists, but it's deprecated. It's been replaced with
BOOST_PROTO_REPEAT and BOOST_PROTO_LOCAL_ITERATE macros. See the docs
for boost/proto/repeat.hpp.

> So how would this be formulated in modern Boost.Proto? I'm guessing
> I will need an expression template wrapper (called Expression<> above) that
> uses some combination of BOOST_PROTO_BASIC_EXTENDS,
> BOOST_PROTO_EXTENDS_SUBSCRIPT and BOOST_PROTO_EXTENDS_FUNCTION. But of course
> not all statements have a valid operator() overload and no expressions do.
> I guess the grammar will take care of that, yes?
>
> I'm really puzzled about how to do the ".else_" part. I was hoping I could
> look to Phoenix to get a clue but it doesn't seem to use Proto.
>
> Any help? Thanks!

There is experimental and undocumented support in Proto for members like
else_. See libs/proto/example/virtual_member.cpp for a working example.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net