summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2018-07-16 15:59:50 +0000
committerOri Bernstein <ori@eigenstate.org>2018-07-19 21:29:58 -0700
commit01d9c59aa0f27db7bd3b9b8c1978c9a65c5e60a0 (patch)
treeb645aee862dfba6071a72985e6b736579e56abb2
parentf4a43f90e3ffe1712aec13566e8ac545da4161c4 (diff)
downloadmc-01d9c59aa0f27db7bd3b9b8c1978c9a65c5e60a0.tar.gz
Add documentation for tuple access expressions
I updated the language spec to mention the feature my previous patch introduces. I also fixed some cross-references en passant.
-rw-r--r--doc/lang.txt24
1 files changed, 19 insertions, 5 deletions
diff --git a/doc/lang.txt b/doc/lang.txt
index 4dc9f12..4b7c482 100644
--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -1149,6 +1149,7 @@ TABLE OF CONTENTS:
Precedence 11:
x.name Member lookup
+ x.N Tuple component access
x++ Postincrement
x-- Postdecremendoc/libstd/varargst
x# Dereference
@@ -1256,10 +1257,10 @@ TABLE OF CONTENTS:
Atomic expressions are the building blocks of expressions, and
are either parenthesized expressions or directly represent
- literals. Literals are covered in depth in section 4.2.
+ literals. Literals are covered in depth in section 5.1.
An identifier specifies a variable, and are looked up via
- the scoping rules specified in section 4.9.
+ the scoping rules specified in section 3.5.
Gap expressions (`_`) represent an anonymous sink value. Anything
can be assigned to a gap, and it may be used in pattern matching.
@@ -1642,7 +1643,20 @@ TABLE OF CONTENTS:
(expr : <seq>).len : @idx
:: integral @a, numeric @a
- 5.2.22: Index:
+ 5.2.22: Tuple Component Access
+
+ expr.N
+
+ Tuple component access operates on tuples. N must be a natural
+ number (i.e., 0, 1, 2, ...) and the type of `expr` must be a tuple
+ type with at least `N+1` components. The result of the expression
+ is an lvalue of the type of the `N+1`th component.
+
+ Type:
+
+ (expr : (@a0, ..., @aN, ...)).N : @aN
+
+ 5.2.23: Index:
expr[idx]
@@ -1659,7 +1673,7 @@ TABLE OF CONTENTS:
(expr : @a[:])[(idx : @idx)] : @a
:: integral, numeric @idx
- 5.2.23: Slice:
+ 5.2.24: Slice:
expr[lo:hi], expr[:hi], expr[lo:], expr[:]
@@ -1681,7 +1695,7 @@ TABLE OF CONTENTS:
(expr : @#)[(lo : @lo) : (hi : @hi)] : @a[:]
:: integral, numeric @lo, integral, numeric @hi
- 5.2.24: Call:
+ 5.2.25: Call:
expr()
expr(arg1, arg2)