Misuse of lex

nigelh at uvicctr.UUCP nigelh at uvicctr.UUCP
Fri Mar 13 08:49:39 AEST 1987


> It is common to use lex to recognize a long list of reserved words
> with constructs like:
> 	options				return (OPTIONS);
> 	precedence			return (PRECEDENCE);
> 	trusted				return (TRUSTED);
>		....

If lex were properly oriented to the user's needs, it would
automatically generate a lexical analyzer that implemented an
efficient look-up technique for the reserved words (hashing would
be my preference).

We gave up on lex a long time ago.  We wrote a replacement tool,
mkscan, that has abandoned the regular-expression idiom and simply
provides an easy-to-use, menu-driven, full-screen interface to
the user.  It does things like ask the user for a list of reserved
words.  When you are finished, out comes a lexical analyzer that is
one-third the size of the equivalent lex-produced code and runs twice
as fast.  Look out for a paper in a forthcoming issue of Software-
Practice and Experience that describes mkscan in more detail.

There is also a tool called GLA developed at the University of
Colorado which handles lists of reserved words in an intelligent
manner.  Look at S-P&E 16 (9) 1986 for a reference to that tool.

	---	Nigel Horspool
		University of Victoria, Canada



More information about the Comp.unix.wizards mailing list