Integrated code formatter

deadalnix deadalnix at gmail.com
Tue Jan 18 12:50:01 UTC 2022


On Tuesday, 18 January 2022 at 05:47:29 UTC, H. S. Teoh wrote:
> On Mon, Jan 17, 2022 at 07:30:53PM -0800, Walter Bright via 
> Digitalmars-d wrote:
>> On 1/17/2022 6:06 PM, deadalnix wrote:
>> > Modern formatter, such as clang-format, use a parser, but 
>> > the parser generates an IR that as nothing to do with the 
>> > traditional AST you'd get out of a regular parser.
>> 
>> What comes to mind is what to do with the comments.
>
> They should be explicitly represented. Ignored by the part that 
> deals with language grammar, but remain in place to be 
> accounted for during formatting.
>
>
> T

Yes, but it's not that simple. See for instance.

int a; // This is an int.
int b;

vs

int a;
// This is an int.
int b;

We understand the comment to be attached to a in the first case, 
while we understand it is attached to b in the second.


More information about the Digitalmars-d mailing list