Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-05-23 06:39:47

----- Original Message -----
From: "joel de guzman" <joel_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, May 22, 2001 8:03 PM
Subject: Re: [boost] Re: [ANN] Spirit C++ parser framework

> ----- Original Message -----
> From: "David Abrahams":
> > Only that sequencing is the most common operation, so it should have the
> > simplest syntax. Since we can't get by with no syntax at all, I don't
> > writing
> >
> > repeat<0>(a) meanting a*
> > repeat<1>(a) meaning a+
> > repeat<3,5>(a) meaning aaa | aaaa | aaaaa
> >
> I still want to keep the prefix +. EBNF and RegEX people are
> already so a accustomed with the + for positive closure. One of
> my goals was to mimic EBNF syntax as much as possible.
> I guess c++ guys wouldn't be so bothered having prefix + for
> the positive closure. We have the prefix * and infix * that does
> different things already. We're used to that. So I'd say:
> +(a + b); // repeat a b zero to zillion times
                            ^^^^ one
but point taken.

> Still the iterator syntax is nice. I'd say:
> loop<0,8>(a); // 0 ~ 8
> loop<8>(a); // exactly 8 times (very useful for parsing files)
> loop<0,_>(a); // zero to infinity (same as kleene star)
> loop<1,_>(a); // one to infinity (same as positive closure)
> loop<0,1>(a); // zero or one (same as optional closure)
> ** The single underscore means: to infinity and beyoooond....
> I've been using a variant of this iterator in another parser generator.
> I am rebuilding that right now on top of Spirit.

One nit: people want "_" for /so/ many things in C++... I am leery of
reserving it for any one use (and it gets to be pretty useless when
namespaces are involved: "boost::_"). So please consider using a default
argument of -1 to mean forever.

loop<0>(a); // zero to infinity (same as kleene star)
loop<1>(a); // one to infinity (same as positive closure)

loop<0,-1>(a); // zero to infinity (same as kleene star)
loop<1,-1>(a); // one to infinity (same as positive closure)

Boost list run by bdawes at, gregod at, cpdaniel at, john at