On 4/24/13 8:04 PM, Graydon Hoare wrote:
My skill at grammar-factoring is ... minimal, but I thought you could
generally factor anything that's just a common-prefix situation like
these by introducing new rules that go one (common) token further and
then decide between the two remaining possible branches. Not to say it's
pretty, but it ... ought to work, I think?

I tried harder to refactor it. 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).

Patrick

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to