Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto]: How to use complex grammars in a domain/extension
From: Eric Niebler (eric_at_[hidden])
Date: 2010-09-21 09:37:26


On 9/21/2010 3:15 AM, Roland Bock wrote:
> That did not make a difference:
>
> // -----------------------------------------------------------------
> #include<complex>
> #include<boost/proto/proto.hpp>
>
> using namespace boost;
>
> struct addition :
> proto::or_
> <
> proto::terminal<proto::_>
> , proto::plus<addition,addition>
> >
> {};
>
> struct equation:
> proto::or_
> <
> proto::equal_to<addition, addition>
> >
> {};
>
> template<class Expr>
> struct extension;
>
> struct my_domain
> : proto::domain<
> proto::pod_generator< extension>
> , equation
> >
> {};
>
>
> template<class Expr>
> struct extension
> {
> BOOST_PROTO_EXTENDS(
> Expr
> , extension<Expr>
> , my_domain
> )
> };
>
> int main()
> {
> extension<proto::terminal<int>::type> i;

Trouble here. The "equation" grammar only matches things of the form "x
== y". The terminal "i" *by itself* is not of that form. You won't be
able to use this terminal at all.

> i == i; // ERROR

As expected. You need to change your grammar to allow lone terminals.

-- 
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