Eric Niebler wrote:
Is it that a vW evaluator is free to try *any* rule in the grammar in
place of the T? If so, that seems FAR too powerful to be useful. Indeed
the wikipedia entry says as much. Instead, it points to CDL
(http://en.wikipedia.org/wiki/Compiler_Description_Language) and affix
grammars as more practical for defining programming languages.
It exactly does that: trues any rules in place of T
What is the "parameter" of a grammar? Do you mean the expression against
which you're evaluating the grammar?
The grammar parameter is the "type" rule in the vW grammar
so i have a grammar:
template<class T> struct simd_grammar : proto::or_< ... > {};
OK. What is T?
Any type that fit in a SIMD terminal ...
and a meta-function:
template<class T> struct is_vectorizable;
What is T, and how is this implemented?
and actually matches this meta-function.
is_vectorizable itself is defined so it check that on current platform,
T has a SIMD equivalent.
Maybe once I understand what you're doing we can find a better way.
I already know how difficult it is to, for instance, ensure that all
terminals in an expression have the same type. That's the problem the
poster who suggested vW grammars had. It doesn't sound like your
technique can help in instances like this.
Here is the simd::grammar<T> grammar:
namespace nt2{ namespace simd
{
namespace bp=boost::proto;
////////////////////////////////////////////////////////////////////////////
// grammar is a template class to avoid a complex, recursive type
matching
// to ensure that SIMD expression of different native source are not
mixed.
////////////////////////////////////////////////////////////////////////////
template<class T, class Cardinal> struct grammar
: bp::or_< bp::and_< bp::terminal< data<T,Cardinal> >
, bp::if_<
meta::is_vectorizable<T,Cardinal>() >
>
, meta::lambda_term< boost::is_arithmetic >
, bp::nary_expr< bp::_, bp::vararg<
grammar<T,CArdinal> > >
> {};
} }
simd::vector<T,Cardinal> then inherit from an expression based on
grammar<T,Cardinal> in a proper subdomain.
Then vector<float,4> can be mixed together but vector<T,4> +
vector<char,16> can't
We are sure all terminal have the same type cause we can't build
expression in a way they will not.
_______________________________________________
proto mailing list
[email protected]
http://lists.boost.org/mailman/listinfo.cgi/proto