From 59ad8145df5e82548b959b9aa078eb1e2cba56f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=A1ulio=20Bezerra?= Date: Sat, 10 Mar 2018 14:46:01 -0300 Subject: [PATCH 1/2] Fixes for the match grammar: - added MatchArms to make things clearer - added attributes to both the match block and match arms - removes pipes before the patterns, since they're experimental --- src/expressions/match-expr.md | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/expressions/match-expr.md b/src/expressions/match-expr.md index 3dbbf43da..a51198057 100644 --- a/src/expressions/match-expr.md +++ b/src/expressions/match-expr.md @@ -2,13 +2,26 @@ > **Syntax** > _MatchExpression_ : ->    `match` [_Expression_]_except struct expression_ _MatchBlock_ +>    `match` [_Expression_]_except struct expression_ `{` +>       [_InnerAttribute_]\* +>       _MatchArms_? +>    `}` > -> _MatchBlock_ : ->       `{` `}` ->    | `{` (`|`? _Pattern_ (`|` _Pattern_)\* (`if` [_Expression_])? `=>` ([_BlockExpression_] `,`? | [_Expression_] `,`))\* ->            (`|`? _Pattern_ (`|` _Pattern_)\* (`if` [_Expression_])? `=>` ([_BlockExpression_] `,`? | [_Expression_] `,`?)) ->       `}` +> _MatchArms_ : +>    ( _MatchArm_ `=>` +> ( [_BlockExpression_] `,`? +> | [_Expression_] `,` ) +> )\* +>    _MatchArm_ `=>` ( [_BlockExpression_] | [_Expression_] ) `,`? +> +> _MatchArm_ : +>    [_OuterAttribute_]\* _MatchArmPatterns_ _MatchArmGuard_ +> +> _MatchArmPatterns_ : +>    _Pattern_ ( `|` _Pattern_ )* +> +> _MatchArmGuard_ : +>    `if` [_Expression_] A `match` expression branches on a *pattern*. The exact form of matching that occurs depends on the pattern. Patterns consist of some combination of @@ -141,4 +154,6 @@ let message = match maybe_digit { [place expression]: expressions.html#place-expressions-and-value-expressions [value expression]: expressions.html#place-expressions-and-value-expressions [`char`]: types.html#textual-types -[numeric types]: types.html#numeric-types \ No newline at end of file +[numeric types]: types.html#numeric-types +[_InnerAttribute_]: attributes.html +[_OuterAttribute_]: attributes.html From ba7414dc63e10e9b8afbfc8bfc8fea3a4662c336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=A1ulio=20Bezerra?= Date: Sat, 10 Mar 2018 17:09:59 -0300 Subject: [PATCH 2/2] Added back the optional pipe before the patterns --- src/expressions/match-expr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/expressions/match-expr.md b/src/expressions/match-expr.md index a51198057..8de9ae0c4 100644 --- a/src/expressions/match-expr.md +++ b/src/expressions/match-expr.md @@ -18,7 +18,7 @@ >    [_OuterAttribute_]\* _MatchArmPatterns_ _MatchArmGuard_ > > _MatchArmPatterns_ : ->    _Pattern_ ( `|` _Pattern_ )* +>    `|`? _Pattern_ ( `|` _Pattern_ )* > > _MatchArmGuard_ : >    `if` [_Expression_]