home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7379 < prev    next >
Encoding:
Internet Message Format  |  1992-12-12  |  947 b 

  1. Path: sparky!uunet!bcstec!galileo!meb4593
  2. From: meb4593@galileo.rtn.ca.boeing.com (Michael Bain)
  3. Newsgroups: comp.lang.perl
  4. Subject: C comment parser?
  5. Message-ID: <1268@galileo.rtn.ca.boeing.com>
  6. Date: 12 Dec 92 00:19:19 GMT
  7. Organization: Boeing Commercial Airplane Group, Seattle
  8. Lines: 18
  9.  
  10. I'm having difficulty developing the regular expression to remove C
  11. comments from a variable (say $_) that contains a C function.  (I'm
  12. hacking a McCabe metric and am reading in a function at a time)  
  13.  
  14. What I have so far seems to work *most* of the time, but oftentimes it
  15. misses an ending C comment delimiter (*/) and ends up removing a lot of
  16. code until it reaches the last delimiter.
  17.  
  18. Here's the RE:
  19.     s?/\*(.*\n)*.*\*/??; # remove comments
  20.  
  21. Does somebody have a better one that works?
  22.  
  23. -- 
  24. Michael Bain                                            (206) 234-6942
  25. Boeing Commercial Airplane Group           meb4593@icdfs.ca.boeing.com
  26. Seattle, WA 98124
  27.  
  28.