I'm a huge rust fan that has had some ideas spinning in my head and wanted to share to see if they're feasible and interesting to folks here.
I'll start by mentioning where this idea came into my head. I was listening to Command Line Heroes Season 7 Episode 3, when the guest Gretchen McCulloch points out how many programming languages are written in english or use english friendly syntax. It was something I hadn't ever considered and encourage folks to give it a listen.
A few weeks go by, and as part of a personal project, I stumble upon ABNF and BNF, tools to describe a syntax for a given language. I started looking into compilers and started to realize, you could generate a parser for any (valid) set of ABNF rules. I started to wonder if Rust, with its edition system which supports "interop" with previous editions, could be used to support multiple syntax's of the language that are more natural to other (non-programming) languages (ex: Spanish, French, Mandarin, etc.).
With the background, I'll try and write out the general proposal.
- Rust will expand it's edition support beyond just 2015, 2018, and 2021 to include 2021-sp, 2021-fr, 2021-etc as well.
- Each edition (moving forward) would map to a set of ABNF (or similar) parser rules that can be used to generate the parser for the given edition.
- The rust compiler uses the corresponding parser for the given edition of the crate based on the edition to generate the AST.
- The rust compiler continues to do what it currently does with the AST after Lexing/Parsing
- (Potentially) easier edition support in the future. Simply add new Rule/remove rules to a given parser
- (Potentially) easier feature support, as again, it would be defined based on a generic Rule
- More inclusive language. Helps grow the community and language even further than where it is today.
- (Potentially) Maintenance. How easy will it be to manage and maintain all of these generic rules, especially when a lot of the rules will represent the same thing with different syntax (ex: "for" and "por" both defined for looping rules)
- Backwards compatibility. This feels like a re-write of the parser today, at least for future editions
- Implementing rule specific parsing features. One of the things the Rust compiler does EXTREMELY well is tell the programming where things went wrong when compiling AND how they might fix it. I'm not sure how this is implemented and how easily/feasible it would be to implement that for these generic rules based parsers
Overall, I may be solving a problem that doesn't need to be solved and adding more trouble than it's worth, but I can't shake this idea until someone tells me it's not going to happen . I've found the Rust community to be very welcoming and felt this may be a way to expand the language and welcome more people to enjoy the language and programming.