regex for C comments

Tom Stockfisch tps at chem.ucsd.edu
Wed Jul 12 14:16:25 AEST 1989


In article <5939 at rpi.edu> flynn at anyguay.acm.rpi.edu (Kevin Lincoln Flynn) writes:
>In article <502 at chem.ucsd.EDU> tps at chem.ucsd.edu (Tom Stockfisch) writes:
>>This expression fails on each of the following:
>>	/*****//hello world */
>  Please correct me if I'm wrong, but I don't believe this is a legal C
>comment.  /*****/ should be a complete comment...  /hello world */ is not
>part of it.  

Precisely.  The given pattern,

	"/*""/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/"

considers

	/hello world */

to be part of the

	/*****/

comment.  I presume the original idea was to have lex pick legal comments
out of C source code.  Given arbitrary preceding and following text,

	/*****//hello world */

is certainly legal C.
-- 

|| Tom Stockfisch, UCSD Chemistry	tps at chem.ucsd.edu



More information about the Comp.lang.c mailing list