[SAOC 2023] dfmt rewrite - Weekly update #11
Prajwal S N
snp at dlang.org
Fri Dec 1 12:33:49 UTC 2023
Hi all,
This week, I completed the pass that enables support for multiple
brace styles - users can now configure between Allman, K&R, OTBS,
and Stroustrup. I also ironed out some weird bugs in the
formatting logic that showed up during the implementation.
One major feature that is still yet to be implemented in dmdfmt
(this seems like a nice name, so I'll use it to refer to the
project going forward) is the ability to preserve comments. The D
parser does not store comment information apart from doc
comments, and currently does not provide a way to store it in the
AST either. I've been scouring the parsing logic and seeing how
this can be added into the DMD library without breaking the
existing API. Ideally, this change should not require us to make
any modifications in the compiler itself, or to users of the DMD
library. The lexer definitely processes comments and spits out a
`TOK.comment` token. We just need to figure out how that can be
stored, and what to do when it is not associated with any other
AST node (a free-standing comment, like in an empty block that
does not generate an AST node).
More information about the Digitalmars-d
mailing list