
8 May
2008
8 May
'08
5:46 p.m.
2008/5/8 Simon Marlow
So basically you want to run a lexer over the source again to collect all the comments?
Yes.
You really want to use GHC's lexer, because otherwise you have to write another lexer.
I don't mind writing a lexer that just collects the comments. It should be simpler than a full Haskell lexer, right? It wouldn't need to handle layout, for instance. Using GHC is also a good option.
So a flag to GHC's lexer that says whether it should return comments or not seems like a reasonable way to go. But if you're doing that, you might as well have the parser collect all the comments off to the side during parsing, to avoid having to lex the file twice, right?
Yes. David