DEV Community

Translating Rust to other languages (Pt 1- Context Free Grammar)

Jeremy Mill on February 03, 2018

Overview At my place of current employment I write libraries in Rust which are called by other languages, on multiple operating systems,...
Collapse
 
benaryorg profile image
#benaryorg

I wonder whether you could use Rust's macro system for the AST creation.
I mean, it already builds an AST there, so you could use a macro that exposes a text version of the AST directly from the Rust compiler.
That way you wouldn't need to re-define the language externally.…

Collapse
 
living_syn profile image
Jeremy Mill

Yup, I think you could. Other people suggested this on Reddit as well. This was fun to write though, and relatively quick