On Apr 25, 2013, at 7:04 AM, Graydon Hoare wrote: > On 13-04-24 11:39 PM, Lindsey Kuper wrote: >> On Thu, Apr 25, 2013 at 1:25 AM, Patrick Walton <pwal...@mozilla.com> wrote: >>> I have an untested grammar for Rust here, >>> with the token regexes not yet filled in: >>> >>> https://gist.github.com/anonymous/5457664 >>> >>> yapps2 reports that this grammar is LL(1). >>> >>> Note that the refactorings I made resulted in a grammar which isn't that >>> great for tooling or parsing in many places. In particular the contortions >>> needed to make `self_ty_and_maybenamed_args` result in an AST that combines >>> the self type and the type of the first argument together in bizarre ways. >>> >>> Since this is untested, I'm sure there are bugs, but it's probably a good >>> sign that I could at least refactor the grammar to what I think is LL(1). >> >> This is really cool, but I'm sort of confused about the apparent >> multiple ongoing efforts toward having a precise and machine-readable >> Rust grammar. Should we consider one of these the "real" grammar? > > This is a translation of the one John just finished (which was for antlr4, a > very flexible "any LL(k)" grammar) into input for yapps2, which (as far as I > know) has the distinguishing features of being-in-python and > being-able-to-tell-us-about-LL(1)-conflicts. I believe it's still the "same" > grammar as John did, just massaged to target a different tool. At some point > I'd like a library that can consume/emit the 97 different equivalent dialects > of EBNF used by different tools, so we can do this sort of exercise a little > more readily. > > In any case that is (as far as I know) the only multiplicity of grammars > floating about. The previous attempt here was one I made, targeting > llnextgen, but it was abandoned mid-way-through (the results of which are > currently on display in the reference manual).
FWIW, I'm (mildly) concerned too. In particular, I'm disappointed to discover that in its present form (and using my present caveman-like invocation style), ANTLR parses source files so slowly that it's impossible to use directly as a validation tool; I would very much like to directly validate the grammar used for documentation purposes against the existing sources. I haven't yet asked for help from the ANTLR folks, because I don't yet feel like I've finished due diligence on RTFMing ANTLR, which I would prefer to do before dumping the problem in their lap. John _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev