www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [SAOC 2023] dfmt rewrite - Weekly update #12

reply Prajwal S N <snp dlang.org> writes:
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 */)`.
Dec 08 2023
parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
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.
Dec 08 2023