Joel Falcou wrote:
I have a grammar with 3 kind of terminal : A,B and C. I want to have a transform that returns a mpl::int_ which is equal to the number of B terminal that appear in expression like :
A(B,B,C,B,C ..)
the grammar part for matching this is currently :
when< function< vargarg
> , mpl::count< _, terminal<B> >() >
First, you want to use mpl::count_if with proto::matches so that you get
the fuzzy terminal matching. Second, it seems that although proto
expressions are valid Fusion sequences, they are not valid mpl
sequences. That's a bug and I'll fix it. The following works for me:
#include <iostream>
#include ()
>
{}; proto::terminal<A>::type a = {{}};
proto::terminal<B>::type b = {{}};
proto::terminal<C>::type c = {{}};
int main()
{
std::cout << CountB()( a(b,c,b,a) ) << std::endl;
}
HTH,
--
Eric Niebler
BoostPro Computing
http://www.boostpro.com