Skip to content

Commit 45649d8

Browse files
authored
Merge pull request #262 from brauliobz/match_grammar
Fixes for the match grammar
2 parents b4c41c7 + ba7414d commit 45649d8

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/expressions/match-expr.md

+22-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22

33
> **<sup>Syntax</sup>**
44
> _MatchExpression_ :
5-
> &nbsp;&nbsp; `match` [_Expression_]<sub>_except struct expression_</sub> _MatchBlock_
5+
> &nbsp;&nbsp; `match` [_Expression_]<sub>_except struct expression_</sub> `{`
6+
> &nbsp;&nbsp; &nbsp;&nbsp; [_InnerAttribute_]<sup>\*</sup>
7+
> &nbsp;&nbsp; &nbsp;&nbsp; _MatchArms_<sup>?</sup>
8+
> &nbsp;&nbsp; `}`
69
>
7-
> _MatchBlock_ :
8-
> &nbsp;&nbsp; &nbsp;&nbsp; `{` `}`
9-
> &nbsp;&nbsp; | `{` (`|`<sup>?</sup> _Pattern_ (`|` _Pattern_)<sup>\*</sup> (`if` [_Expression_])<sup>?</sup> `=>` ([_BlockExpression_] `,`<sup>?</sup> | [_Expression_] `,`))<sup>\*</sup>
10-
> &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; (`|`<sup>?</sup> _Pattern_ (`|` _Pattern_)<sup>\*</sup> (`if` [_Expression_])<sup>?</sup> `=>` ([_BlockExpression_] `,`<sup>?</sup> | [_Expression_] `,`<sup>?</sup>))
11-
> &nbsp;&nbsp; &nbsp;&nbsp; `}`
10+
> _MatchArms_ :
11+
> &nbsp;&nbsp; ( _MatchArm_ `=>`
12+
> ( [_BlockExpression_] `,`<sup>?</sup>
13+
> | [_Expression_] `,` )
14+
> )<sup>\*</sup>
15+
> &nbsp;&nbsp; _MatchArm_ `=>` ( [_BlockExpression_] | [_Expression_] ) `,`<sup>?</sup>
16+
>
17+
> _MatchArm_ :
18+
> &nbsp;&nbsp; [_OuterAttribute_]<sup>\*</sup> _MatchArmPatterns_ _MatchArmGuard_
19+
>
20+
> _MatchArmPatterns_ :
21+
> &nbsp;&nbsp; `|`<sup>?</sup> _Pattern_ ( `|` _Pattern_ )<sup>*</sup>
22+
>
23+
> _MatchArmGuard_ :
24+
> &nbsp;&nbsp; `if` [_Expression_]
1225
1326
A `match` expression branches on a *pattern*. The exact form of matching that
1427
occurs depends on the pattern. Patterns consist of some combination of
@@ -141,4 +154,6 @@ let message = match maybe_digit {
141154
[place expression]: expressions.html#place-expressions-and-value-expressions
142155
[value expression]: expressions.html#place-expressions-and-value-expressions
143156
[`char`]: types.html#textual-types
144-
[numeric types]: types.html#numeric-types
157+
[numeric types]: types.html#numeric-types
158+
[_InnerAttribute_]: attributes.html
159+
[_OuterAttribute_]: attributes.html

0 commit comments

Comments
 (0)