Re: is lex useful?

bromage@cs.mu.OZ.AU (Andrew Bromage)
2 Jul 1996 12:32:56 -0400

          From comp.compilers

Related articles
[19 earlier articles]
Re: is lex useful? Robert.Corbett@Eng.Sun.COM (1996-06-30)
Re: is lex useful? leichter@smarts.com (1996-06-30)
Re: is lex useful? trd@murlibobo.cs.mu.OZ.AU (1996-06-30)
Re: is lex useful? WStreett@shell.monmouth.com (1996-06-30)
Re: is lex useful? dmr@bell-labs.com (1996-06-30)
Re: is lex useful? clark@quarry.zk3.dec.com (1996-07-01)
Re: is lex useful? bromage@cs.mu.OZ.AU (1996-07-02)
Re: is lex useful? kanze@lts.sel.alcatel.de (1996-07-02)
Re: is lex useful? colas@aye.inria.fr (1996-07-04)
Re: is lex useful? trd@lister.cs.mu.OZ.AU (1996-07-05)
| List of all articles for this month |
From: bromage@cs.mu.OZ.AU (Andrew Bromage)
Newsgroups: comp.compilers
Date: 2 Jul 1996 12:32:56 -0400
Organization: Comp Sci, University of Melbourne
References: 96-06-101 96-06-118 96-06-123
Keywords: lex

G'day all.


Jerry Leichter <leichter@smarts.com> wrote:


> The biggest problem I have with lexical analysis generators is that they
> do a lot of work to solve problems that aren't really all that
> important.
> [deletia]
> The few cases where identifiers are *not* trivial, it's their regexp's
> that are not trivial. I recall one language in which an identifier
> was letter followed by letters, digits, or underscores, except that
> you could not have two consecutive underscores.


Problems like this can often be fixed by using a richer set of operators.
Regular sets are closed under operations such as set difference, and if
your favourite scanner generator had it as an operator, this expression
could be expressed very neatly as:


<<
alpha [a-zA-Z]
sym [a-zA-Z0-9_]


%%


{alpha}{sym}* - .*"__".*
>>


Another example is the C comment, which could be expressed:


<<
any (.|"\n")


%%


"/*"({any}* - {any}*"*/"{any}*)"*/"
>>


Cheers,
Andrew Bromage
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.