catala icon indicating copy to clipboard operation
catala copied to clipboard

Formatter for Catala code

Open EmileRolley opened this issue 3 years ago • 4 comments
trafficstars

As suggered in #252, adding a formatter to the Catala toolkit could be a great improvement for both the developer and the reviewer experience. Catala being a literate programming language, having a good readability of the code is essential.

Proposals

  1. A first step could consist of the addition of a new Format backend using the surface AST of the compiler.
  2. A second one could be done by implementing a standalone program using for instance Tree-sitter in order to take advantage of the incremental parsing.

EmileRolley avatar May 03 '22 09:05 EmileRolley

Additionally, this could allow automatic translation from one Catala dialect to another, e.g. French to Engish.

AltGr avatar May 23 '22 13:05 AltGr

Indeed, except for variable names...

denismerigoux avatar May 23 '22 15:05 denismerigoux

Update: it's still in progress, but I have a working tree-sitter parser at https://github.com/AltGr/tree-sitter-catala

and the included catala.el file contains an emacs mode (for emacs 29+) that can do automatic indentation based on it.

AltGr avatar Apr 13 '23 09:04 AltGr

The easiest way for formatting Catala at this point will be to use https://github.com/AltGr/tree-sitter-catala and https://github.com/tweag/topiary

AltGr avatar Oct 24 '23 12:10 AltGr