merlyn@iwarp.intel.com (Randal Schwartz) (07/13/89)
In article <502@chem.ucsd.EDU>, tps@chem (Tom Stockfisch) writes: | So, who has the shortest single LEX expression that correctly | matches C comments -- | ignoring string and character constants, | and disallowing start conditions? | | Mine is | | "/*"\/*([^/]|{[^*/]\/+})*"*/" What are these curly brace things? They're not used in accordance with V7 (the One True Unix :-) Lex. OK, I'll toss my submission back in the ring, which I have tested (for once... :-). "/*"("*"*[^*/]+|"/"+)*"*"+"/" You could make it shorter by leaving off the two plus signs inside the parens, but this is probably more efficient. Ducking to avoid the onslaught of test cases, -- /== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\ | on contract to Intel, Hillsboro, Oregon, USA | | merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn | \== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/