February 22, 2015
On Sunday, 22 February 2015 at 08:48:16 UTC, Brian Schott wrote:
> On Friday, 20 February 2015 at 02:21:01 UTC, Brian Schott wrote:
>> dfmt is a D source code formatting tool.
>>
>> https://github.com/Hackerpilot/dfmt/
>> https://github.com/Hackerpilot/dfmt/releases/tag/v0.1.0
>
> I just tagged 0.1.1. The only change is a bug fix for a case where certain long lines with parenthesis wouldn't wrap properly.

v0.1.2 is tagged... "Move fast: things are broken", or something like that.
February 22, 2015
"Brian Schott"  wrote in message news:updwbngwrilngxhunzon@forum.dlang.org...

> dfmt is a D source code formatting tool.
>
> https://github.com/Hackerpilot/dfmt/
> https://github.com/Hackerpilot/dfmt/releases/tag/v0.1.0

Is this on code.dlang.org?  I can't find it. 

February 22, 2015
On Sunday, 22 February 2015 at 09:07:16 UTC, Brian Schott wrote:
> On Sunday, 22 February 2015 at 08:48:16 UTC, Brian Schott wrote:
>> On Friday, 20 February 2015 at 02:21:01 UTC, Brian Schott wrote:
>>> dfmt is a D source code formatting tool.
>>>
>>> https://github.com/Hackerpilot/dfmt/
>>> https://github.com/Hackerpilot/dfmt/releases/tag/v0.1.0
>>
>> I just tagged 0.1.1. The only change is a bug fix for a case where certain long lines with parenthesis wouldn't wrap properly.
>
> v0.1.2 is tagged... "Move fast: things are broken", or something like that.

Just submitted a PR to include pesky braces a la
https://twitter.com/thedirtycoder/status/569339014085517312
February 22, 2015
On Sunday, 22 February 2015 at 09:07:16 UTC, Brian Schott wrote:
> On Sunday, 22 February 2015 at 08:48:16 UTC, Brian Schott wrote:
>> On Friday, 20 February 2015 at 02:21:01 UTC, Brian Schott wrote:
>>> dfmt is a D source code formatting tool.
>>>
>>> https://github.com/Hackerpilot/dfmt/
>>> https://github.com/Hackerpilot/dfmt/releases/tag/v0.1.0
>>
>> I just tagged 0.1.1. The only change is a bug fix for a case where certain long lines with parenthesis wouldn't wrap properly.
>
> v0.1.2 is tagged... "Move fast: things are broken", or something like that.

Congratulations to releasing. :)

For the record, I think using a D parser in dfmt is a dead end. Surely, for certain cases the additional information is necessary. However, it restricts dfmt to only format syntactically valid snippets. This means you cannot (in general) format parts of a file, e.g. within a diff or editor.

Example where parsing helps: "foo : bar" or "foo: bar" depending on the context. The former within import statements, the latter within switch statements.

Example for a snippet you cannot parse: The body of a switch statement without the switch. The 'case' keyword would be an error.

Effectively, you want to parse, but not with a normal parser. Great formatting seems to require a special (more flexible, less correct) parser. This is what clang-format does.
February 23, 2015
On 2015-02-22 19:52, qznc wrote:

> Congratulations to releasing. :)
>
> For the record, I think using a D parser in dfmt is a dead end. Surely,
> for certain cases the additional information is necessary. However, it
> restricts dfmt to only format syntactically valid snippets. This means
> you cannot (in general) format parts of a file, e.g. within a diff or
> editor.
>
> Example where parsing helps: "foo : bar" or "foo: bar" depending on the
> context. The former within import statements, the latter within switch
> statements.
>
> Example for a snippet you cannot parse: The body of a switch statement
> without the switch. The 'case' keyword would be an error.

It depends on how the parser is implemented. For example, the Eclipse Java parser is very flexible when it comes to this. You can choose to either parse a complete file or just a fragment of code.

> Effectively, you want to parse, but not with a normal parser. Great
> formatting seems to require a special (more flexible, less correct)
> parser. This is what clang-format does.

clang-format uses the lexer with the help of the parser. It only changes whitespace. At least according to the talk I watched, which is a couple of years old.

-- 
/Jacob Carlborg
March 03, 2015
On 2/19/2015 6:21 PM, Brian Schott wrote:
> dfmt is a D source code formatting tool.
>
> https://github.com/Hackerpilot/dfmt/
> https://github.com/Hackerpilot/dfmt/releases/tag/v0.1.0

Thanks for doing this. It's an important part of the D toolchain we need to have. At some point I want to merge it into the official release.

I noticed it is remarkably small (1400 lines). What is its algorithm? How does it compare with gofmt and clang-format in how it works?
March 03, 2015
On Tuesday, 3 March 2015 at 20:36:20 UTC, Walter Bright wrote:
> Thanks for doing this. It's an important part of the D toolchain we need to have. At some point I want to merge it into the official release.
>
> I noticed it is remarkably small (1400 lines). What is its algorithm? How does it compare with gofmt and clang-format in how it works?

I haven't read the source to either of those programs, so I'm not sure how it compares.

dfmt works by re-using my existing lexer and parser. The parser is run on the code first so that the formatting step knows a few things like the difference between the binary and unary forms of "*". Line splitting is figured out using a badly mangled version of A*.
March 04, 2015
On Tue, 03 Mar 2015 12:35:44 -0800, Walter Bright wrote:

> On 2/19/2015 6:21 PM, Brian Schott wrote:
>> dfmt is a D source code formatting tool.
>>
>> https://github.com/Hackerpilot/dfmt/ https://github.com/Hackerpilot/dfmt/releases/tag/v0.1.0
> 
> Thanks for doing this. It's an important part of the D toolchain we need to have. At some point I want to merge it into the official release.
> 
> I noticed it is remarkably small (1400 lines). What is its algorithm? How does it compare with gofmt and clang-format in how it works?

i bet dfmt parses the source and then regenerates it from scratch using AST it built. with all the work Brian put into his D parsing libraries, the main driver can be relatively small, i think.

March 04, 2015
On Tue, 2015-03-03 at 23:03 +0000, Brian Schott via Digitalmars-d-announce wrote:
> 
[…]
> dfmt works by re-using my existing lexer and parser. The parser  is run on the code first so that the formatting step knows a few things like the difference between the binary and unary forms of "*". Line splitting is figured out using a badly mangled version  of A*.

Does this mean dfmt uses the same parser as the D D compiler?

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


March 04, 2015
On Wednesday, 4 March 2015 at 07:43:44 UTC, Russel Winder wrote:
> On Tue, 2015-03-03 at 23:03 +0000, Brian Schott via Digitalmars-d-announce wrote:
>> 
> […]
>> dfmt works by re-using my existing lexer and parser. The parser  is run on the code first so that the formatting step knows a few  things like the difference between the binary and unary forms of  "*". Line splitting is figured out using a badly mangled version  of A*.
>
> Does this mean dfmt uses the same parser as the D D compiler?

No. https://github.com/Hackerpilot/libdparse