On Apr 25, 2013, at 9:16 AM, Graydon Hoare wrote:

> On 13-04-25 08:33 AM, Paul Stansifer wrote:
> 
>> (For example: suppose that some statements and some expressions shared a
>> common prefix that had to be merged in order to make the grammar LL(1);
>> instead of having `stmt` and `expr` nonterminals in macros, we'd need to
>> split them into `most_stmt` `most_expr` and `some_stmt_and_expr`.)
> 
> That would of course be undesirable. It is not clear to me that the 
> factorings patrick was struggling with had that property. I think both 
> suffixes of 'unsafe' were inside $stmt (branching to sub-rules shared by 
> $item and $expr) and both suffixes of '&' were branching to sub-rules of $ty 
> and $pat. But I might be misreading. I agree that we want to keep relatively 
> pithy named entrypoints in the grammar for the macro nonterminal parser to 
> hook in at (even if they're artificial). Difficult balancing act, but I think 
> it may be possible. Or at least it's not evident to me yet that it's not.

FWIW, I strongly suspect that the LL(1)-refactoring of the grammar will not be 
as nice to use for documentation purposes as a non-LL(1) one. In my eyes, the 
principal virtue of ANTLR 4 is the ability to specify a grammar that is easily 
readable for humans, and can easily be split up into documentation.

To take a really simple example, consider 

IMPL type LBRACE … RBRACE
and
IMPL trait FOR type LBRACE … RBRACE

I think we'd probably like to preserve the ability to present these as separate 
and complete rules in separate parts of the manual.

This is much more true for parts of the expression grammar, but I don't want to 
get bogged down in details.

Naturally, the proof of the pudding is in the eating.

Apologies if I've misunderstood you.

John

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

Reply via email to