[SAOC 2023] dfmt rewrite - Weekly update #6
Prajwal S N
snp at dlang.org
Fri Nov 3 19:25:48 UTC 2023
On Thursday, 2 November 2023 at 15:05:39 UTC, Imperatorn wrote:
> Are there any plans on extending ASTBase?
At the moment, no. `ASTBase` was created to provide a mechanism
to build a complete AST and traverse it without having to do any
of the semantic analysis passes. Unfortunately, this means that
the classes used to represent the nodes in `ASTBase` are
different from the ones used in `ASTCodegen`. There are certain
missing features which prevent us from using it for cases where
we need access to the tokens present in a node (e.g. the name of
an identifier, or the body of a function). Extending it for our
use case would not help, since the formatter needs to be able to
walk the AST and write the tokens in each node in order to obtain
the original source code. Since the compiler uses `ASTCodegen`,
the nodes provided by it contain the correct tokens, and also
contain the methods required to meaningfully generate a string
representation of those tokens.
More information about the Digitalmars-d
mailing list