[m-dev.] For review: general purpose lexer module

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Feb 13 03:10:37 AEDT 2001


On 12-Feb-2001, Ralph Becket <rbeck at microsoft.com> wrote:
> > > % Some useful single-char regexps.
> > > 
> > > :- pragma memo(digit/0).
> > > :- pragma memo(lower/0).
> > > :- pragma memo(upper/0).
> > > :- pragma memo(wspc/0).
> > > :- pragma memo(dot/0).
> > > 
> > > digit      = any("0123456789").
> > > lower      = any("abcdefghijklmnopqrstuvwxyz").
> > > upper      = any("ABCDEFGHIJKLMNOPQRSTUVWXYZ").
> > > wspc       = any(" \t\n\r\f\v").
> > > dot        = anybut("\n").
> > > alpha      = (lower \/ upper).
> > > alphanum   = (alpha \/ digit).
> > > identstart = (alpha \/ atom('_')).
> > > ident      = (alphanum \/ atom('_')).
> > > nl         = atom('\n').
> > > tab        = atom('\t').
> > > spc        = atom(' ').
> > 
> > I think it would be helpful to document why you chose to use
> > `pragma memo' for some of these but not all of them.
> 
> Will do.  The idea here is that these things are (a) common and
> (b) take *some* time to compute and (c) are constants, hence it's
> worth telling the compiler to memo them.  Are these redundant?

No, they're not redundant.

> Will the compiler fully evaluate constant functions?

It may in some cases, but probably not most of the time, and probably
not here.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list