Cool, John beat me to the punch and posted a grammar to a repository!

(And better still, John's grammar looks way more complete than my own.)

I went ahead and shoved my version of Rust.g4 into a branch on a fork of your repo, so that people can skim and compare the approaches. (E.g. the use of named terminals such a LPAREN versus hard-coding them as literals in the productions.)

https://github.com/pnkfelix/rust-antlr/blob/pnkfelix-draft-from-rust-manual/Rust.g4

Note the above link is not expected to actually work on real rust expressions of any size. I was working by transcribing from the manual; I infer that John took a much different tack, perhaps using the parser source as a basis...? In any case, I am posting this mostly to stimulate thought as to what tack to take that will best integrate both with our code and also with our documentation.

Cheers,
-Felix


On Mon Mar 25 21:23:32 2013, John Clements wrote:
Following an offhand comment of Patrick's on Friday, I decided to take a look 
and see just how easy it is to formulate an ANTLR grammar. The answer is: very, 
very easy. I wrote up a simple grammar for Rust tokens; it's up at

https://github.com/jbclements/rust-antlr/

The tokens work great, and so does a simple token-tree parser; it can now parse 
large rust files into token trees. I started adding an AST-level parser, but it's 
just got bits & pieces of the grammar, for now.

John

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev



--
irc: pnkfelix on irc.mozilla.org
email: {fklock, pnkfelix}@mozilla.org

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to