Git Product home page Git Product logo

rust-antlr's Introduction

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

rust-antlr's People

Contributors

jbclements avatar

Stargazers

Cedric avatar Lemon avatar  avatar 邱维东 avatar EchoBai avatar  avatar Matt Price avatar Luis Montero avatar Aarmn the limitless avatar fun avatar Crimson avatar  avatar  avatar Emily Herbert avatar jolestar avatar  avatar yflau avatar ypcpy avatar ik5 avatar Dendi Suhubdy avatar  avatar subhasis maity avatar timtang avatar Xargin avatar  avatar Anatoly I avatar Alex Zenla avatar Dave Raffensperger avatar  avatar Niek Haarman avatar Francisco Nebrera avatar  avatar Federico Tomassetti avatar Roman Bartusiak avatar Alexandre Nicastro avatar Tobe Osakwe avatar jadon avatar Adam Cook avatar Eimrine's Point of View avatar Sudeep Hazra avatar Pedro Larroy avatar devty avatar Daniel Fagnan avatar Piotr Kukiełka avatar  avatar Vic Goldfeld avatar  avatar Paul Meng avatar Lindsey Kuper avatar Patrick Walton avatar Joohun, Maeng avatar Felix S Klock II avatar Huon Wilson avatar Graydon Hoare avatar Brian Anderson avatar

Watchers

 avatar James Cloos avatar drrb avatar

rust-antlr's Issues

License

I'd like to include your ANTLR grammar in a NetBeans plugin that I'm creating, and would like to attribute the grammar to you.

Is the grammar currently available under an open source license? If not, would you mind making it so? I plan to license the plugin under GPLv3, so any compatible license on your part would work for me. Specifically, I'd be most happy with GPLv3 or Apache 2.

Thanks!

Unable to generate using Rust.g4

Using the following command
java -jar E:/Tutorials/Rust/parsing/antlr-4.7.1-complete.jar Rust.g4

I am getting the following errors.

error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:56:7: syntax error: '"'
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:56:16: syntax error: '"'
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:56:20: syntax error: '"'
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:56:28: syntax error: '"'
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:380:4: syntax error: ''
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:380:5: syntax error: '
'
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:461:4: syntax error: ''
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:461:5: syntax error: '
'
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:610:4: syntax error: ''
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:610:5: syntax error: '
'
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:713:0: syntax error: ''
came as a complete surprise to me
error(50): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:713:1: syntax error: '
'
came as a complete surprise to me
warning(156): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:790:11: invalid escap
e sequence "
warning(156): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:790:25: invalid escap
e sequence "
warning(156): E:\Tutorials\Rust\parsing\rust-antlr\Rust.g4:828:47: invalid escap
e sequence "

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.