grailbio / reflow

A language and runtime for distributed, incremental data processing in the cloud
Apache License 2.0
965 stars 52 forks source link

Automatic code formatter #125

Closed josh-newman closed 4 years ago

josh-newman commented 4 years ago

Introduces a reflow fmt command.

The formatter handles most reflow programs I've tested, except:

The formatter places newlines judiciously, including allowing up to one blank line between lines. It uses identifier punning when possible, elides function argument types when possible, writes declaration comments, etc. It always chooses := for assignment unless the left side is destructuring or a type is ascribed. This was necessary to handle declaration lists in make, requires, etc. without parser changes, for now, but I actually think this is nice because I dislike having multiple ways of writing anything.

It makes no effort to format invalid syntax.