www.digitalmars.com         C & C++   DMDScript  

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

reply Prajwal S N <snp dlang.org> writes:
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.
Oct 06 2023
parent reply max haughton <maxhaton gmail.com> writes:
On Friday, 6 October 2023 at 16:20:07 UTC, Prajwal S N wrote:
 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.
Are you trying to write your own formatter inspired by dfmt or rewrite dfmt to use dmd's code?
Oct 06 2023
parent Prajwal S N <snp dlang.org> writes:
On Friday, 6 October 2023 at 16:21:29 UTC, max haughton wrote:
 Are you trying to write your own formatter inspired by dfmt or 
 rewrite dfmt to use dmd's code?
I'm refrctoring dfmt to use DMD's code, but it's not a simple one-to-one port due to the differences between libdparse and DMD.
Oct 14 2023