catala
catala copied to clipboard
Formatter for Catala code
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
- A first step could consist of the addition of a new
Formatbackend using the surface AST of the compiler. - 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.
Additionally, this could allow automatic translation from one Catala dialect to another, e.g. French to Engish.
Indeed, except for variable names...
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.
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