[rust-dev] figuring out grammar for generics

Niko Matsakis niko at alum.mit.edu
Thu Mar 21 13:12:48 PDT 2013


That looks about right, though

(1) as we said on IRC `&static` ought to be changed to `'static` (or, 
eventually, any lifetime name).
(2) I presume lifetimes = lifetime | lifetime, lifetimes
(3) we typically allow trailing commas, and we probably do here as well 
(or at least probably should?).


Niko

> John Clements <mailto:clements at brinckerhoff.org>
> March 21, 2013 3:07 PM
> I'm just fixing a few bugs, and trying to make sure I understand the 
> grammar of generics. Here's what I've got. Can someone correct me, if 
> I'm wrong? I've lifted comments from a couple of functions, so you can 
> ignore the words "matches" and "where". Also, the definition of 'ty' 
> is not provided :). I'm assuming a hopefully-obvious BNF syntax.
>
> John
>
>
>
> // matches generics = ( ) | ( < > ) | ( < typaramseq > ) | ( < 
> lifetimes > ) | ( < lifetimes , typaramseq > )
> // where typaramseq = ( typaram ) | ( typaram , typaramseq )
>
> // matches typaram = IDENT optbounds
>
> // matches optbounds = ( ( : ( boundseq )? )? )
> // where boundseq = ( bound + boundseq ) | ( bound )
> // and bound = ( & STATIC ) | ( ty )
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20130321/952e0410/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1360 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20130321/952e0410/attachment.jpg>


More information about the Rust-dev mailing list