December 08

Hi all,

I spent this week working on adding support for storing comments in DMD. The lexer currently stores doc comments along with the token, but ignores regular comments. A new rawComment field in struct Token is introduced, that gets populated during lexing. This feature is restricted to DMD as a library (version (DMDLIB) {...}) since it is effectively useless for the compiler itself. Now that the lexer provides this information, the parser can populate the AST nodes with it (again, only while using DMD as a library). This should now enable us to not lose comments while formatting with dmdfmt, although I'm yet to figure out how these comments will be inserted into the formatted output, and whether this strategy would work for inline comments, e.g. something like fn foo(int a /* Arg 1 */, int b /* Arg 2 */).

December 09
It may be a good idea to put these comments under a different version.

Not all users of dmd-fe will require access to such comments and storage will be quite great. Such as auto-completion.