Skip to content

Grammar for tuple and tuple indexing expressions #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/expressions/tuple-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Tuple expressions

> **<sup>Syntax</sup>**
> _TupleExpression_ :
> &nbsp;&nbsp; &nbsp;&nbsp; `(` `)`
> &nbsp;&nbsp; | `(` ( [_Expression_] `,` )<sup>+</sup> [_Expression_]<sup>?</sup> `)`

Tuples are written by enclosing zero or more comma-separated expressions in
parentheses. They are used to create [tuple-typed](types.html#tuple-types)
values.
Expand All @@ -22,6 +27,10 @@ comma:

## Tuple indexing expressions

> **<sup>Syntax</sup>**
> _TupleIndexingExpression_ :
> &nbsp;&nbsp; [_Expression_] `.` [TUPLE_INDEX]

[Tuples](types.html#tuple-types) and [struct tuples](items/structs.html) can be
indexed using the number corresponding to the position of the field. The index
must be written as a [decimal literal](tokens.html#integer-literals) with no
Expand All @@ -36,3 +45,6 @@ assert_eq!(pair.1, 2);
let unit_x = Point(1.0, 0.0);
assert_eq!(unit_x.0, 1.0);
```

[TUPLE_INDEX]: tokens.html#integer-literals
[_Expression_]: expressions.html