I am thinking about trying a slightly different syntax for Rust on my own, for fun. Surely one can write a source-to-Rust compiler, but for the scope I'm wanting to implement and given that it's only a syntactical difference, I believe it would be more straightforward to modify the parser itself in the source.
I used the word "dialect" in the title because that's the terminology used in Rackett, although I am using it in the reduced sense of changing the syntax. In Rackett you can use
#lang dialect on top file to specify which one you want. I would prefer to use a different file extension although, if that's somehow not possible, a similar approach to Rackett: if the file starts with
// lang: [name], then it's parsed using this custom syntax; otherwise, it's normal Rust.
- Has anyone played around with this idea before?
- Is it as straightforward as tweaking rustc-parse?
- If you have examples in mind, could you point me to MRs on Github which significantly change the syntax? As an idea of which files are touched and the effort involved
Thanks in advance