Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!agate!ucbvax!ucsd!chem.ucsd.edu!tps From: tps@chem.ucsd.edu (Tom Stockfisch) Newsgroups: comp.lang.c Subject: Re: regex for C comments Message-ID: <503@chem.ucsd.EDU> Date: 12 Jul 89 04:16:25 GMT References: <19365@paris.ics.uci.edu> <502@chem.ucsd.EDU> <5939@rpi.edu> Reply-To: tps@chem.ucsd.edu (Tom Stockfisch) Distribution: na Organization: Chemistry Dept, UC San Diego Lines: 29 In article <5939@rpi.edu> flynn@anyguay.acm.rpi.edu (Kevin Lincoln Flynn) writes: >In article <502@chem.ucsd.EDU> tps@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@chem.ucsd.edu