Comment recognition in Lex, again
anderson at uwvax.ARPA
anderson at uwvax.ARPA
Fri May 4 08:41:08 AEST 1984
<>
I have received several replies to my request for a lex expression
to recognize /* ... */ comments. The only one that works (sent in
by Jim Hogue) is
"/*"([^*]*"*"*"*"[^/*])*[^*]*"*"*"*/"
which I can't claim to fully understand. Nor do I understand why my
original, "/*"([^*]|("*"/[^/]))*"*/", doesn't work. The idea is that
each character in the string between /* and */ can either be something
other than *, or * followed by something other than /.
Can anyone come up with an expression simpler than Hogue's that works?
By "works", I mean put it in a real "lex" program, as in:
(your expr) printf("recognized (%s)\n",yytext);
and try it on inputs such as /***/, /*/*/, etc.
-- David Anderson (uwvax!anderson)
More information about the Comp.unix.wizards
mailing list