Comment recognition in Lex, agai - (nf)
johnl at haddock.UUCP
johnl at haddock.UUCP
Tue May 8 13:40:56 AEST 1984
#R:watmath:-766600:haddock:16800012:000:685
haddock!johnl May 7 14:28:00 1984
The problem with recognizing comments as single Lex tokens is that Lex
has a finite sized token buffer. If your comments are bigger than the
buffer, you lose.
What should work is to put in a COMMENT start state and do this:
"/*" BEGIN COMMENT; /* start a comment */
<COMMENT>"*/" BEGIN 0; /* return to regular state */
<COMMENT>.|\n ; /* throw everything else away */
Unfortunately, I've never had much luck with making lex programs that
include start states work. Everybody lets lex recognize the /* and
writes C code to eat the comment; if you read the manual page for lex,
you'll find exactly that in the example.
John Levine, ima!johnl
More information about the Comp.unix.wizards
mailing list