All Projects → jbclements → rust-antlr

jbclements / rust-antlr

Licence: other
An ANTLR grammar for Rust

Programming Languages

ANTLR
299 projects
racket
414 projects

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].