home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!uniteq
- From: uniteq@netcom.com (Uniteq Application Systems)
- Subject: Re: Wanted: program to extract comments from C
- Message-ID: <1992Dec26.095028.29823@netcom.com>
- Organization: Uniteq Application Systems
- References: <1h580nINN11p@life.ai.mit.edu>
- Date: Sat, 26 Dec 1992 09:50:28 GMT
- Lines: 20
-
- In article <1h580nINN11p@life.ai.mit.edu> kenneths@ai.mit.edu (Kenneth J. Schneider) writes:
- >well, i just hacked this lex file together:
- >
-
- It's OK, but you could also do it with a lot fewer lines (and a much
- more complicated engine, but we let lex worry about that stuff):
-
- %%
- "//".* {printf("%s\n", yytext); /* C++ comments */ }
- "/*"([^*]|\*+[^*/])*\*+\/ {printf("%s\n", yytext); /* std C comments */ }
- .|\n { /* ignore everything else */ }
-
- I am uncertain about the correct semantics when mixing the two commenting
- styles - the above code allows `//' to comment out a `/*' but not a `*/'.
- The code Kenneth presented took the rather strange (IMO) stance of making
- either type of comment able to override the other (`//' remains active
- within a `/* ... */' pair).
-
- Enjoy,
- - Jeff.
-