Boost logo

Proto :

Subject: Re: [proto] talking proto
From: joel falcou (joel.falcou_at_[hidden])
Date: 2010-07-17 02:20:26

Eric Niebler wrote:
> Thanks for the links. Some good bedtime reading for me. But obviously if
> C++ is the host language, then a DSEL's syntax is necessarily
> constrained to that of C++. That rules out nifty tricks like
> meta-programming C++ in C++ a-la Lisp or Haskell. You can't make that
> pig fly. Maybe the answer is to just use Haskell, but that's not
> something I can tell proto's users. ;-)
You can also look at metaOCAML and the paper by Czarnescky et al. on
comparison between DSL design in C++, Haskell and Caml.
I've uploaded it here:

Now, with respect to Haskell/ML, we have some idea running here to have
a ML based DSL design API that use the power of ML to help the designer
valdiate the languages (because ML type checker is really good at
helping us) and once the design is done in ML, generate the valdiated,
certified, proto based C++ code for the user to use. That's something I
have as a research target for the upcoming year.
> Someone on the dev list brought up Van Wijngaarden grammars. I haven't tried to implement them yet (mostly
> because I don't understand them). There are probably lots of other good
> ideas out there.
Basically VW grammar are "template grammars" aka grammar that match
parametric rules for which the set of acceptable parameter are
themselves defined by a rule.

An example can be:

definition ::= T varid;
T ::= {bool,integer}

This grammar match

bool a;
integer b;

but fail on

float c;

Basically in proto, it is a template grammar which is coupled with a
meta-function validating the parameter of said grammar.
I use some for our SIMD grammar to:
1/ have different grammar based on the SIMD base type and control their mix
2/ restrict said grammar to types that make sense on given platform to
be vectorized.

so i have a grammar:

template<class T> struct simd_grammar : proto::or_< ... > {};

and a meta-function:

template<class T> struct is_vectorizable;

Currently I replaced all match call by our own match that take a type
and a grammar and see if it fits both the grammar and the metafunction
but I guess it could be done better.

Proto list run by eric at