|
Boost : |
From: joel de guzman (joel_at_[hidden])
Date: 2001-05-25 22:09:13
From: "Larry Evans" :
> "John (EBo) David" wrote:
>
> > From: "joel de guzman":
> > >
> > > From: "Douglas Gregor":
> >
> > haven't though much about it, but how about "digit[0][2]" or
> > "(a|b|c)[0][more]" instead...
> > couldn't that work?
> >
>
> I think the problem here is what's the type of digit[0]? If it's
> like arrays, then digit is rank2, digit[0] is rank1, and digit[0][2]
> is rank0. On the other hand, if you claim that all are rank 0, then
> how do you distinguish whether the i in Parser::operator[](int i) is for
the min
> or max repititions of *this?
>
I certainly can do this in the framework. In my other post:
> How about:
>
> a[2]; // exactly 2
> a[0][2]; // 0..2
> a[0][more]; // 0...
> a[1][more]; // 1...
>
> This can be done.
>
> Joel de Guzman
>
> PS> Do I hear yuck?
Greg Colvin said: Yuck. I rather see a.repeat(0,more) or repeat<0,more>(a).
But really, a little bit of indirection and object substitution, I can do
that.
If you look into the Longest[] directive (Spirit_Directives.h), the operator
switches an Alternative<> object into a LongestAlternative<> object.
For [][] iterators I see a pseudo code:
ExactIterator Parser::operator[](uint n);
first level..... e.g. a[8]; do a 8 times
then
FiniteIterator ExactIterator::operator[](uint n);
InfiniteIterator ExactIterator::operator[](More_);
second level finite e.g. a[8][16]; ... do a 8 to 16 times
and second level infinite e.g. a[8][more] ... do a 8 or more times
see my other post re: more and the More_ class
Cheers,
Joel de Guzman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk