Ticket #13 (closed feature request: fixed)
Add support for comments
|Reported by:||nibro||Owned by:||nibro|
|Priority:||blocker||Milestone:||Full document support|
Description (last modified by nibro) (diff)
This is an overarching ticket that will be broken down into smaller pieces as I get closer and start picking at the details.
The overall goal is to support a round-trip parser and pretty-printer so that pretty . parse == id. This requires a number of additions to the current library:
- The AST must be embellished with support for comments. These will not be interspersed in the actual AST (unless we want to give special treatment to Haddock comments), instead residing in a separate structure along the AST.
- We must have a (presumably two pass) parser that handles both code and comments, and remembers exact source locations for both.
- The pretty-printer is probably the most involved. It must print the AST and comments exactly as they were parsed, at the exact same line and column. This will probably require an entirely new pretty-printer, leaving the old one as it stands for simple usage.
There are some open issues here too, such as what to do with trailing whitespace, and what to do with tabs. I'm currently leaning towards discarding trailing whitespace and transforming tabs into 8 spaces.