# Parsing another language into rust

**URL:** <https://internals.rust-lang.org/t/parsing-another-language-into-rust/6333>\
**Category:** Uncategorized\
**Created:** [December 2, 2017, 4:46pm UTC](https://internals.rust-lang.org/t/parsing-another-language-into-rust/6333 "2017-12-02T16:46:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vityafx](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/vityafx/32/2146_2.png) [@vityafx](https://internals.rust-lang.org/u/vityafx)\
**Post date:** [December 2, 2017, 4:46pm UTC](https://internals.rust-lang.org/t/parsing-another-language-into-rust/6333/1 "2017-12-02T16:46:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)\
**Post date:** [December 2, 2017, 4:54pm UTC](https://internals.rust-lang.org/t/parsing-another-language-into-rust/6333/2 "2017-12-02T16:54:19Z")

</div>

You can build Rust syntax reliably using [https://github.com/dtolnay/quote](https://github.com/dtolnay/quote) (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).

---

<div class="post-metadata">

**Author:** ![djc](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/djc/32/1592_2.png) [@djc](https://internals.rust-lang.org/u/djc)\
**Post date:** [December 3, 2017, 8:17am UTC](https://internals.rust-lang.org/t/parsing-another-language-into-rust/6333/3 "2017-12-03T08:17:32Z")

</div>

[Askama](https://github.com/djc/askama) parses (with nom) Jinja-like templates and generates Rust code for them through a custom derive macro.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:29am UTC](https://internals.rust-lang.org/t/parsing-another-language-into-rust/6333/4 "2019-03-25T08:29:19Z")

</div>

Closed on March 25, 2019, 8:29am UTC

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