Stripping Haskell comments

Nicholas Nethercote njn25@cam.ac.uk
Mon, 18 Mar 2002 15:35:54 +0000 (GMT)


On Mon, 18 Mar 2002, Kevin Glynn wrote:

>  > Are there any programs to strip comments and blank lines from a Haskell
>  > source file, that work on normal and literate programs?
>
> Doing a real job is 'hard' (e.g. nested block comments, -- may
> actually start a lexeme ...)
>
> For a simple job that does well usually see
>
> fptools/ghc/compiler/count_lines
>
> in the ghc distribution.

Unfortunately that doesn't even handle multi-line "{- ... -}" comments...
So I hacked up this wretched slice of Perl to do the job.  I'm surprised
there aren't programs out there that do this properly.

--
Nick Nethercote
njn25@cam.ac.uk