Grammar specification for Rust

Would it be possible for Rust to adopt an official grammar specification? It seems like right now, the implementation is the specification, which means you have to dive through dozens of files and thousands of lines of code to figure out what the syntax actually is.

It appears that around a year and a half ago, there was an effort to specify the Rust grammar, but it sadly seems to be abandoned and incomplete.


This document is pretty accurate in my experience. I've found it to be a usable base for implementing accurate syntax highlighting, anyway.

The ungrammar that rust-analyzer uses can also be useful. It doesn't tell you how to parse the tokens, and it doesn't disambiguate anything, but it does a pretty good job at showing humans what the syntax of Rust looks like.


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