An ANTLR grammar for Rust

License: Apache-2.0

Language: 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.

Project Statistics

Sourcerank 4
Repository Size 76.2 KB
Stars 30
Forks 6
Watchers 2
Open issues 0
Dependencies 0
Contributors 1
Tags 0
Last updated
Last pushed

Top Contributors See all

John Clements

Something wrong with this page? Make a suggestion

Last synced: 2017-11-24 20:14:47 UTC

Login to resync this repository