turner@sdti.UUCP (Prescott K. Turner) (04/07/88)
In article <262@nyit.UUCP>, michael@nyit.UUCP (Michael Gwilliam) answered the question, >"Can C comments be filtered out with LEX as regular expressions?" The answer >"Yes, but it may not be a good idea." is the right one. He goes on to say >_Introduction_to_Compiler_Construction_with_Unix_, by Axel T. Schreiner and >H. George Friedman, Jr., Prentice-Hall, 1985, on page 25 gives: > > "/*""/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/" I did not notice the original question on the net, but recently struggled with the same regular expression problem. So I respect the above solution, even though it erroneously matches /***//*/ as a complete comment. Here is a correct regular expression for a C comment: "/*""/"*("*"*[^*/]"/"*)*"*"*"*/" -- Prescott K. Turner, Jr. Software Development Technologies, Inc. 375 Dutton Rd., Sudbury, MA 01776 USA (617) 443-5779 UUCP:...genrad!mrst!sdti!turner