Skip to content

harpocrates/language-rust

Repository files navigation

Parser and pretty printer for the Rust language Build Status

language-rust aspires to efficiently and accurately parse and pretty-print the Rust language. The underlying AST structures are also intended to be as similar as possible to the AST rustc uses itself. When language-rust and rustc have diverging AST, the divergence should be detailed in the documentation.

Building with Stack

With the Stack tool installed, you should only need to run

stack init
stack install

The second command is responsible for pulling in all of the dependencies (including executable tools like Alex, Happy, and GHC itself) and then compiling everything.

Evolution of Rust

As Rust evolves, so will language-rust. We will make a best effort to support unstable features from nightly as they come out, but in general will only target compatibility with stable.

Bugs

Parser

Any difference between what is accepted by the rustc parser and the language-rust parser indicates

  • a bug in language-rust (this is almost always the case)
  • a bug in rustc
  • that there is a newer version of rustc which made a breaking change to this syntax

If the AST/parser of rustc changes, the rustc-tests test suite should start failing - it compares the JSON AST debug output of rustc to our parsed AST.

Pretty-printer

For the pretty-printer, bugs are a bit tougher to list exhaustively. Suggestions for better layout algorithms are most welcome! The fmt-rfcs repo is loosely used as the reference for "correct" pretty-printing.