Path: utzoo!attcan!uunet!mcvax!ukc!mucs!ian From: ian@ux.cs.man.ac.uk (Ian Cottam) Newsgroups: comp.lang.c Subject: Re: request for C comment stripper Message-ID: <5693@ux.cs.man.ac.uk> Date: 19 Mar 89 17:12:54 GMT Organization: Computer Science, University of Manchester, UK Lines: 30 I usually use a lex script for such things. I didn't have one for C, but the following might do the trick. N.B. Not tested, not proven, no warranty! ________________________________________________________________________ %{ /***** Lex script to strip comments from C texts ******/ %} %s COMMENT STRING CHAR %% \' {BEGIN CHAR; ECHO;} \" {BEGIN STRING; ECHO;} "/*" BEGIN COMMENT; . ECHO; \n ECHO; \\' ECHO; \' {ECHO; BEGIN INITIAL;} \\\" ECHO; \" {ECHO; BEGIN INITIAL;} "*/" BEGIN INITIAL; . ; \n ; %% ----------------------------------------------------------------- Ian Cottam, Room IT101, Department of Computer Science, University of Manchester, Oxford Road, Manchester, M13 9PL, U.K. Tel: (+44) 61-275 6157 FAX: (+44) 61-275-6280 ARPA: ian%ux.cs.man.ac.uk@nss.cs.ucl.ac.uk JANET: ian@uk.ac.man.cs.ux UUCP: ..!mcvax!ukc!mur7!ian -----------------------------------------------------------------