On 13-04-24 07:06 PM, Patrick Walton wrote:

These were the only warnings that the Python yapps2 module emitted when
compiling the Rust grammar, after suitable refactoring. My general
feeling is that, given how valuable explicit self and argument patterns
are, LL(2) is okay, especially if we turn out to be LALR(1). Others may
feel differently, however; thoughts?

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?

(TBH I don't actually understand any of the examples I can find of LL(2) grammars that "can't be factored into LL(1)"; the compiler texts I have all suggest that you can factor most reasonable LL(*) things into LL(1) with sufficiently many intermediate nodes. This page for example shows one http://stackoverflow.com/questions/10634197/ll2-language-that-is-not-ll1 but I can't tell exactly what's going on there, something to do with having to look 1 token past a choice point that may expand infinitely? It seems quite rare / unlikely.)

If we absolutely, resolutely can't factor the current grammar down to LL(1) I guess I'll live. LL(2) is not the end of the world. But it seems awfully close, given the results so far! 2 or 3 remaining conflicts? That's _amazing_. I thought we'd be fighting this for months.

I agree that removing pattern arguments and explicit self would be a high price, probably too high, if that's what it comes down to.

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

Reply via email to