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 */)
.