summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2012-08-14 18:13:00 -0400
committerOri Bernstein <orib@google.com>2012-08-14 18:13:00 -0400
commit482ea3b5682f4a34c30ddc3546424ba1f8429bf7 (patch)
treec3f31f0baf59c85ad054c11cf6fdc31fbba5900f
parente24bcc37239283534785e2e2a31393f20ae6c9b7 (diff)
downloadmc-482ea3b5682f4a34c30ddc3546424ba1f8429bf7.tar.gz
Use ':' instead of ',' in slice ranges.
It's clearer notation, IMO.
-rw-r--r--parse/gram.y2
-rw-r--r--test/outparam-sl.myr2
-rw-r--r--test/slice.myr2
-rw-r--r--test/slicelen.myr2
4 files changed, 4 insertions, 4 deletions
diff --git a/parse/gram.y b/parse/gram.y
index 78fd582..2538ea3 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -502,7 +502,7 @@ postfixexpr
{$$ = mkexpr($1->line, Opostdec, $1, NULL);}
| postfixexpr Tosqbrac expr Tcsqbrac
{$$ = mkexpr($1->line, Oidx, $1, $3, NULL);}
- | postfixexpr Tosqbrac optexpr Tcomma optexpr Tcsqbrac
+ | postfixexpr Tosqbrac optexpr Tcolon optexpr Tcsqbrac
{$$ = mksliceexpr($1->line, $1, $3, $5);}
| postfixexpr Toparen arglist Tcparen
{$$ = mkcall($1->line, $1, $3.nl, $3.nn);}
diff --git a/test/outparam-sl.myr b/test/outparam-sl.myr
index 37bddbf..8e21c0c 100644
--- a/test/outparam-sl.myr
+++ b/test/outparam-sl.myr
@@ -1,6 +1,6 @@
const arr = [1,2,3,4]
const f = {out
- *out = arr[1,3]
+ *out = arr[1:3]
}
const main = {
diff --git a/test/slice.myr b/test/slice.myr
index 9bd2d10..1f492a9 100644
--- a/test/slice.myr
+++ b/test/slice.myr
@@ -2,7 +2,7 @@ const main = {
var a : int[3]
var s
- s = a[,]
+ s = a[:]
s[0] = 3
s[1] = 4
s[2] = s[0] + s[1] + s.len
diff --git a/test/slicelen.myr b/test/slicelen.myr
index ed28ba0..1b35cea 100644
--- a/test/slicelen.myr
+++ b/test/slicelen.myr
@@ -2,6 +2,6 @@ const main = {
var a : int[8]
var s
- s = a[1,6]
+ s = a[1:6]
-> s.len
}