How would you build a DSL?

For my ledger-cli port I am now working on a feature that enables the user to specify a report format using a domain specific language. This is very flexible for the advanced user, who will be able to create reports tailored to specific needs. I will use it myself to automate some of my tax requirements.

Not knowing any better, I am doing this using pest, which I think is an elegant way to do it. But I was wondering, how would you go about it?

I think pest is a great option if you are defining your own format.

The other option I would consider is using an existing format like TOML, if there is a well-supported one that meets your requirements.

1 Like

Iā€™m doing the same (i.e. writing a DSL) and I rely on pest for that.
It makes the job without a lot of stuff.
I think pest is quite a good tool.

Nevertheless, I noticed one weakness if your DSL file could be large (more than thousands of lines): the location in the file using pest API (i.e. using start_pos from pest::Span) could be slow.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.