Path: utzoo!mnetor!uunet!husc6!linus!philabs!sbcs!nyit!michael From: michael@nyit.UUCP (Michael Gwilliam) Newsgroups: comp.lang.c Subject: LEX Message-ID: <260@nyit.UUCP> Date: 1 Feb 88 22:32:53 GMT Organization: Computer Graphics Lab, New York Institue of Technology Lines: 41 Keywords: LEX, comments, C, regular expression Summary: Is there a regular expression to discard C comments in LEX I'm writting a C like language to discribe data structures. When I was writting the tokenizer using LEX and I got intrigued by a little problem. Is it possible to write a regular expression that will transform a /* comment */ into nothing? I tried something like \/\*[^(\/\*)]*\*\/ ; which works pretty good, but won't handle cases like /* comment /* more comment */ which is legal in C. Then somebody came up with something like... \/\*(.\*)\*\/ ; which works pretty good, but it doesn't reject /* /* nested comment */ */ which are illlegal. So my question is, to all you experienced lex users and compiler writers, can this be done? Or do I need to use input() and other lex functions. I imagine that the lex code would be similar in pascal. Thanks for the help or at least reading this far. michael P.S. If reponses are mailed instead of posted, I will be happy to summerize the results and post them myself, giving proper credit where it is due. nyit!michael philabs!nyit!michael ihnp4!philabs!nyit!michael