Steve Klabnik

rust-antlr: An ANTLR grammar for Rust

I just heard about a neat new project: rust-antlr. Basically, it’s an ANTLR grammar for Rust.

Unfortunately, if you’re not a compiler nerd, you may not know what that means.

At the highest level of detail, implementations of a language’s grammar are useful even outside of the compiler itself. For example, syntax highlighting tools, static analysis tools, and alternate language implementations are all good usages of a grammar that’s separate from the official language implementation. So, this project should help out anyone wanting to do something along those lines.

More specifically, ANTLR is a tool for writing grammars. You can write an ANTLR grammar, then have it generate a bunch of code that you can compile into a project, or use standalone as a grammar checker.

Anyway, as the README shows, it’s pretty easy to get started:

1. install antlr 4 jar, put it in your classpath
2. run make
3. try java org.antlr.v4.runtime.misc.TestRig Rust tts -tree <

That’s it! I’m excited to see some tooling pop up around Rust, and hopefully this will enable even more neat tools to be built.


Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00