Skip to content

Commit a8755cc

Browse files
Merge pull request #263 from brauliobz/tuple_expr_grammar
Grammar for tuple and tuple indexing expressions
2 parents 20c4393 + a9d6907 commit a8755cc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/expressions/tuple-expr.md

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Tuple expressions
44

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

2328
## Tuple indexing expressions
2429

30+
> **<sup>Syntax</sup>**
31+
> _TupleIndexingExpression_ :
32+
> &nbsp;&nbsp; [_Expression_] `.` [TUPLE_INDEX]
33+
2534
[Tuples](types.html#tuple-types) and [struct tuples](items/structs.html) can be
2635
indexed using the number corresponding to the position of the field. The index
2736
must be written as a [decimal literal](tokens.html#integer-literals) with no
@@ -36,3 +45,6 @@ assert_eq!(pair.1, 2);
3645
let unit_x = Point(1.0, 0.0);
3746
assert_eq!(unit_x.0, 1.0);
3847
```
48+
49+
[TUPLE_INDEX]: tokens.html#integer-literals
50+
[_Expression_]: expressions.html

0 commit comments

Comments
 (0)