Boost logo

Boost :

From: joel de guzman (joel_at_[hidden])
Date: 2001-05-25 18:52:31


From: "Greg Colvin" :

> From: joel de guzman <joel_at_[hidden]>
> > From: "Greg Colvin":
> >
> > > I wonder if Rule could be given an operator() or operator[] to let you
> > > specify a postfix repetition count, e.g.
> > >
> > > identifier = letter(1,MORE) + (letter | digit)(0,MORE)
> > >
> > > or
> > >
> > > identifier = letter[1,MORE] + (letter | digit)[0,MORE]
> > >
> >
> > That's very cool! Of course we can do that, these are all
> > expression objects that can have the [] overloaded. But I still
> > have the passion for the prefix + and * in addition to this.
> > See the post of andy.elvey_at_[hidden] for a 'newbie'
> > perspective.
>
> I don't care that much about prefix + and *, but it
> seems people who don't like them don't have to use
> them, so long as they have an alternative they do
> like.

JDG: Yes, you don't have to use 'em if you don't want 'em.

>
> > BTW, is MORE a macro? A constant? Nice touch.
>
> A constant, probably -1.
>
> > Isn't there an inf constant somewhere in the floating point
> > math libs? we can definitely reuse that.
>
> Sure, if you want to use float instead of int.

JDG: How about something like:

class More_ {} more;

IteratedParser Parser::operator () (uint first);
IteratedParser Parser::operator () (uint first, uint last);
IteratedParser Parser::operator () (uint first, More_ last);

>
> > > I also wonder if the need for these isn't strongest in the "lexer"
> > > part of most grammars, in which case integrating regex may be the
> > > best solution anyway,
> >
> > I always intended to subsume the lexer. I, for one, am not a
> > fan of posix style regular expressions. Reading one gives me
> > a headache. Here's a sample from boost::regex:
> >
> > "<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"
> >
> > Arghh, give me an aspirin!
>
> Me too. But what does the above look like in Spirit?
>
> > I'd like Spirit to be usable as a preprocessor, and a lexer
> > as well.
>
> It can remain a lexer for those who wnat to use it that
> way, but since Boost has a regex, and since regex is an
> efficient and popular way to write lexers, it seems a
> shame not to integerate it.
>
> > Have a nice day,
> > Joel de Guzman
> >
> > PS> May I post this conversation on to boost?
>
> Of course. Done.
>
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk