Parsing another language into rust

It is interesting to me, are there any crates which can parse custom grammar into a rust grammar to be compiled after? For example, I want to create another language ontop of rust, so I need to create a translator which translates my new language into rust or directly into rust’s ast suitable for rustc compiler.

I am not sure, but I think I saw such crate half year ago somewhere in github, but I can’t find it now.

You can build Rust syntax reliably using (previously it was done by syntex_syntax::pprint).

Apart from that I think you need to pick a parser (e.g. nom) and translate your language into Rust (entirely up to you).

1 Like

Askama parses (with nom) Jinja-like templates and generates Rust code for them through a custom derive macro.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.