Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!ig!arizona!rupley From: rupley@arizona.edu (John Rupley) Newsgroups: comp.lang.c Subject: Re: Want a way to strip comments from a Summary: This one fails, too Message-ID: <9833@megaron.arizona.edu> Date: 22 Mar 89 08:34:32 GMT References: <7150@siemens.UUCP> <9900010@bradley> <4896@cbnews.ATT.COM> <852@lynx.zyx.SE> Organization: U of Arizona CS Dept, Tucson Lines: 29 In article <852@lynx.zyx.SE>, pem@spunk.zyx.SE (Per-Erik Martin) writes: > Here's another example in C. It *is* a piece of cake (15 minutes work). > The problem can be described with a simple automata which is easily coded > in in C (with goto's, >yech<). I've tested it on most of the pathological > examples given in this group and it seems to work. This one fails, too. Try: /***/ hi there /**/ Goes to show, for a quick and clean coding of a pattern-matching automaton, think Lex. The Lex source that was posted is so simple it would be hard to get the logic wrong. Two out of two C postings suggest that it may be easier to err in coding the same automaton in C. Not to imply that C has no advantages -- following comparison is for size of source and for time of uncommenting main.c of an emacs distribution: timex/real wc -l 13.95 10 eatLex.l Lex 2.53 37 eatC.c C code that works 1:27.13 78 eat.sed Maarten L's recently posted sed script (more lines than the C code :-) :-) John Rupley rupley!local@megaron.arizona.edu