Hi, we wanted to implement a custom whitespace formatter powered by a Lezer grammar, for a PostgreSQL esque language. We also want this to work as a VS Code extension.
For this, is getting a parse tree, printing it recursively with appropriate whitespaces inserted, according to specified conditions for specific tokens, a possible approach to implement this? If possible, is it a good approach?
Should be possible. But not easy, I expect—good formatters for most languages are really hard to write, and that difficulty is mostly in the decisions about where line breaks go, not the parsing.