Skip to content

Commit 2c7bf1a

Browse files
committed
Grammar for tuple and tuple indexing expressions
1 parent e490727 commit 2c7bf1a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/expressions/tuple-expr.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## Tuple expressions
44

5+
> **<sup>Syntax</sup>**
6+
> _TupleExpression_ :
7+
> &nbsp;&nbsp; &nbsp;&nbsp; `(` `)`
8+
> &nbsp;&nbsp; | `(` [_Expression_] `,` `)`
9+
> &nbsp;&nbsp; | `(` [_Expression_] (`,` [_Expression_] )<sup>\+</sup>
10+
> `,`<sup>?</sup> `)`
11+
512
Tuples are written by enclosing zero or more comma-separated expressions in
613
parentheses. They are used to create [tuple-typed](types.html#tuple-types)
714
values.
@@ -22,6 +29,10 @@ comma:
2229

2330
## Tuple indexing expressions
2431

32+
> **<sup>Syntax</sup>**
33+
> _TupleIndexingExpression_ :
34+
> &nbsp;&nbsp; [_Expression_] `.` [INTEGER_LITERAL]
35+
2536
[Tuples](types.html#tuple-types) and [struct tuples](items/structs.html) can be
2637
indexed using the number corresponding to the position of the field. The index
2738
must be written as a [decimal literal](tokens.html#integer-literals) with no
@@ -36,3 +47,6 @@ assert_eq!(pair.1, 2);
3647
let unit_x = Point(1.0, 0.0);
3748
assert_eq!(unit_x.0, 1.0);
3849
```
50+
51+
[INTEGER_LITERAL]: tokens.html#integer-literals
52+
[_Expression_]: expressions.html

0 commit comments

Comments
 (0)