[SAOC 2023] dfmt rewrite - Weekly update #3

Prajwal S N snp at dlang.org
Fri Oct 6 16:20:07 UTC 2023


Hi all,


I had mentioned in my previous update that I was looking into a 
purely lexer-based formatting implementation. I realised this 
wouldn't work due to poor error handling, lack of semantic 
information, and poor future-proofing in case we want to add 
context-sensitive format rules going forward. For these reasons, 
it would be ideal to use an AST instead.

Across the last week, I've been working on getting an existing 
pass to use the DMD AST (specifically, the pass to format 
comments). Currently, dfmt traverses the entire tree and stores 
the locations of each type of token, and later operates on the 
token stream. I'm trying to see if there's a way to directly 
operate on the AST without having to store the location 
information.


More information about the Digitalmars-d mailing list