From 45e4259bb20ad6ceee20c8f03e0854b503ad84f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=A1ulio=20Bezerra?= Date: Thu, 30 Nov 2017 00:41:37 -0300 Subject: [PATCH 1/2] Struct grammar --- src/items/structs.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/items/structs.md b/src/items/structs.md index 1a863411a8..1dc4541cc5 100644 --- a/src/items/structs.md +++ b/src/items/structs.md @@ -1,5 +1,41 @@ # Structs +> **Syntax** +> _Struct_ : +>       _StructStruct_ +>    | _TupleStruct_ +> +> _StructStruct_ : +>    `struct` +> [IDENTIFIER]  +> [_Generics_]? +> [_WhereClause_]? +> ( `{` _StructFields_? `}` | `;` ) +> +> _TupleStruct_ : +>    `struct` +> [IDENTIFIER]  +> [_Generics_]? +> `(` _TupleFields_? `)` +> [_WhereClause_]? +> `;` +> +> _StructFields_ : +>    _StructField_ (`,` _StructField_)\* `,`? +> +> _StructField_ : +>    [_OuterAttribute_]\* +>    [_Visibility_]? +>    [IDENTIFIER] `:` [_Type_] +> +> _TupleFields_ : +>    _TupleField_ (`,` _TupleField_)\* `,`? +> +> _TupleField_ : +>    [_OuterAttribute_]\* +>    [_Visibility_]? +>    [_Type_] + A _struct_ is a nominal [struct type] defined with the keyword `struct`. An example of a `struct` item and its use: @@ -43,3 +79,10 @@ The precise memory layout of a struct is not specified. One can specify a particular layout using the [`repr` attribute]. [`repr` attribute]: attributes.html#ffi-attributes + +[_OuterAttribute_]: attributes.html +[IDENTIFIER]: identifiers.html +[_Generics_]: items.html#type-parameters +[_WhereClause_]: items.html#type-parameters +[_Visibility_]: visibility-and-privacy.html +[_Type_]: types.html From c20b106a20fc39e26d0994aff57b19a512474fc6 Mon Sep 17 00:00:00 2001 From: Havvy Date: Wed, 7 Feb 2018 10:30:10 -0800 Subject: [PATCH 2/2] Remove extraneous ?s in struct grammar The visibility grammar already has `EMPTY` as an option. --- src/items/structs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/items/structs.md b/src/items/structs.md index 1dc4541cc5..26f3421d5a 100644 --- a/src/items/structs.md +++ b/src/items/structs.md @@ -25,7 +25,7 @@ > > _StructField_ : >    [_OuterAttribute_]\* ->    [_Visibility_]? +>    [_Visibility_] >    [IDENTIFIER] `:` [_Type_] > > _TupleFields_ : @@ -33,7 +33,7 @@ > > _TupleField_ : >    [_OuterAttribute_]\* ->    [_Visibility_]? +>    [_Visibility_] >    [_Type_] A _struct_ is a nominal [struct type] defined with the keyword `struct`.