Shantonu Sen wrote:
>I've written a new date lexer, which you can find in sbr/dtimep.lex. It:
>1) works
>2) works with flex (I admittedly have not tried it with lex, although it
>   works in flex's lex compatibility mode, if that means anything).

I did a bit of testing on the systems at work:

on AIX 4.3.3 lex fails with

$ make dtimep.c
lex -nit dtimep.lex > dtimep.c
Error: 1285-328 There is not enough memory for final processing.
make: *** [dtimep.c] Error 1

lex has a few options for playing with the memory. I'll see if I can
get a patch to you that doesn't break the flex version.

Solaris 2.7 lex fails with:

lex -nit dtimep.lex > dtimep.c
lex: illegal option -- i
Usage: lex [-ewctvnVY] [-Q(y/n)] [file]

AT&T lex does not support the '-i' case insesitive flag. To simulate
it, you need to write character translations. I don't recall the
exact syntax, but it's something like:

#ifndef FLEX_SCANNER
[aA]    a
[bB]    b
...
#endif

However, even running it minus the -i, it still fails:

$ lex -nt dtimep.lex > dtimep.c
"dtimep.lex":line 2: Error: missing translation value

I'm not sure AT&T lex supports the %option syntax in flex.
IRIX (6.4/6.5) lex fails with exactly the same errors as Solaris.
flex seems to work just fine on all of the above, of course.

>3) works without any "sed hackery", as was mentioned a few weeks ago.

Awesome :-)

>I've set the Makefile so that a make clean will not delete the lexed
>dtimep.c, so that users don't need to keep relexing dtimep.lex (unless
>dtimep.lex changes, obviously). Are there any compelling reasons to
>have it regenerated every time?

Actually, it's probablly a good idea to keep the .c file in the
distribution and generate it only if $(LEX) is defined in the
Makefile. That way, users won't necessarily have to install flex
if their system doesn't already have some lexer.

Going a step further, just keep a flex-lexed .c version available,
and only re-lex it if the installed $(LEX) is actually flex. Doing
so would somewhat avoid the compatibility problems above. And unlike
the old reliance on AT&T lex, it's actually possible to get flex
and install it if it doesn't come with your system.

>If you come across any date formats that something like scan or sortm
>can't handle, drop me a line or add the format to dtimep.lex. The
>easiest way to test this is probably to run sortm, since it will throw
>back any messages it couldn't parse.

I've had problems in the past when using nmh on news files. They may
be worthwhile for stress-testing it.

--
Doug Morris
Morris Communications & Computer Services, Inc.
http://www.mhost.com/

Reply via email to