An ANTLR grammar for Rust
ANTLR Racket Other
Switch branches/tags
Nothing to show
Latest commit 0bc79f0 Mar 9, 2016 @jbclements add apache license
Permalink
Failed to load latest commit information.
.gitignore updated gitignore May 2, 2013
LICENSE-2.0.txt add apache license Mar 9, 2016
Makefile add clean rule Mar 30, 2013
README.md
Rust-massaged.g4 massaged May 9, 2013
Rust.g4 add apache license Mar 9, 2016
antlr-parser.rkt
parses-slowly.rs added comment to parses-slowly.rs May 9, 2013
rust-file-list.rkt refactoring (merge with previous) May 2, 2013
rust-lexer.rkt
rust-parser.rkt
test-driver.rkt just fiddling with constants May 9, 2013
test-rackety-driver.rkt just fiddling with constants May 9, 2013
tests.txt
xidcont.g4 initial commit Mar 23, 2013
xidstart.g4 initial commit Mar 23, 2013

README.md

rust-antlr

An ANTLR grammar for Rust

The ANTLR grammar works in two modes. First, it can parse whole files as sequences of "token trees". Second, it can parse them as Rust programs. It's not worth getting into the differences here; suffice it to say that parsing as token trees essentially just tests the lexer, and makes sure that the delimiters match.

The token-tree parsing appears to successfully parse all readily-available Rust code.

The full parser also appears to parse all readily-available Rust code, although it's SO SLOW that I'm having trouble checking.

To try it out:

  • install antlr 4 jar, put it in your classpath
  • run make
  • try java org.antlr.v4.runtime.misc.TestRig Rust tts -encoding UTF-8 < foo.rs

or, if you want to parse using the full program parser, replace this last line with

  • try java org.antlr.v4.runtime.misc.TestRig Rust prog -encoding UTF-8 < foo.rs

This generates no output on success, and error output on failure.

If you want to see the tree produced by the parser, you can pass the "-tree" argument.

This work is licensed under the Apache License, version 2.0