Want a way to strip comments from a
John Rupley
rupley at arizona.edu
Wed Mar 22 18:34:32 AEST 1989
In article <852 at lynx.zyx.SE>, pem at 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 at megaron.arizona.edu
More information about the Comp.lang.c
mailing list