summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-07-09 21:57:07 -0400
committerOri Bernstein <ori@eigenstate.org>2014-07-09 21:57:07 -0400
commite002242442a548429f014ec3a5c30f1d40799a7a (patch)
tree8b94add5dc476fede0e4345646b23aba8317a263
parent73d297264fae92c1e716f05e5f42496fad95dd37 (diff)
downloadmc-e002242442a548429f014ec3a5c30f1d40799a7a.tar.gz
Change syntax for tuples.
-rw-r--r--libstd/bigint.myr4
-rw-r--r--libstd/floatbits.myr4
-rw-r--r--libstd/optparse.myr2
-rw-r--r--libstd/utf.myr2
-rw-r--r--libstd/varargs.myr4
-rw-r--r--parse/gram.y16
-rw-r--r--test/align.myr6
7 files changed, 20 insertions, 18 deletions
diff --git a/libstd/bigint.myr b/libstd/bigint.myr
index ab7cb8c..813e4ce 100644
--- a/libstd/bigint.myr
+++ b/libstd/bigint.myr
@@ -37,7 +37,7 @@ pkg std =
const bigmul : (a : bigint#, b : bigint# -> bigint#)
const bigdiv : (a : bigint#, b : bigint# -> bigint#)
const bigmod : (a : bigint#, b : bigint# -> bigint#)
- const bigdivmod : (a : bigint#, b : bigint# -> [bigint#, bigint#])
+ const bigdivmod : (a : bigint#, b : bigint# -> (bigint#, bigint#))
const bigshl : (a : bigint#, b : bigint# -> bigint#)
const bigshr : (a : bigint#, b : bigint# -> bigint#)
@@ -352,7 +352,7 @@ const bigmod = {a : bigint#, b : bigint# -> bigint#
}
/* a /= b */
-const bigdivmod = {a : bigint#, b : bigint# -> [bigint#, bigint#]
+const bigdivmod = {a : bigint#, b : bigint# -> (bigint#, bigint#)
/*
Implements bigint division using Algorithm D from
Knuth: Seminumerical algorithms, Section 4.3.1.
diff --git a/libstd/floatbits.myr b/libstd/floatbits.myr
index 50930a8..991be48 100644
--- a/libstd/floatbits.myr
+++ b/libstd/floatbits.myr
@@ -3,8 +3,8 @@ pkg std =
const float32bits : (flt : float32 -> uint32)
const float64frombits : (bits : uint64 -> float64)
const float32frombits : (bits : uint32 -> float32)
- const float64explode : (flt : float64 -> [bool, uint64, int32])
- const float32explode : (flt : float64 -> [bool, uint64, int32])
+ const float64explode : (flt : float64 -> (bool, uint64, int32))
+ const float32explode : (flt : float64 -> (bool, uint64, int32))
;;
const float64bits = {flt; -> (&flt castto(uint64#))#}
diff --git a/libstd/optparse.myr b/libstd/optparse.myr
index 0da8aae..45f2100 100644
--- a/libstd/optparse.myr
+++ b/libstd/optparse.myr
@@ -25,7 +25,7 @@ pkg std =
;;
const optinit : (optstr: byte[:], optargs : byte[:][:] -> optctx#)
- const optnext : (ctx : optctx# -> [char, byte[:]])
+ const optnext : (ctx : optctx# -> (char, byte[:]))
const optdone : (ctx : optctx# -> bool)
const optfin : (ctx : optctx# -> byte[:][:])
;;
diff --git a/libstd/utf.myr b/libstd/utf.myr
index 672ca05..16c3cbb 100644
--- a/libstd/utf.myr
+++ b/libstd/utf.myr
@@ -10,7 +10,7 @@ pkg std =
const charlen : (chr : char -> size)
const encode : (buf : byte[:], chr : char -> size)
const decode : (buf : byte[:] -> char)
- const striter : (str : byte[:] -> [char, byte[:]])
+ const striter : (str : byte[:] -> (char, byte[:]))
;;
const charlen = {c
diff --git a/libstd/varargs.myr b/libstd/varargs.myr
index f7b7ffb..bcaac76 100644
--- a/libstd/varargs.myr
+++ b/libstd/varargs.myr
@@ -4,7 +4,7 @@ pkg std =
type valist
const vastart : (args : ...# -> valist)
- generic vanext : (ap : valist -> [@a, valist])
+ generic vanext : (ap : valist -> (@a, valist))
;;
type valist = byte#
@@ -22,7 +22,7 @@ const vastart = {args
-> args castto(valist)
}
-generic vanext = {ap -> [@a, valist]
+generic vanext = {ap -> (@a, valist)
var v : @a
var align
var p
diff --git a/parse/gram.y b/parse/gram.y
index 6a6cd1b..5a711f3 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -139,7 +139,7 @@ static void addtrait(Type *t, char *str);
%type <node> littok literal asnexpr lorexpr landexpr borexpr
%type <node> bandexpr cmpexpr unionexpr addexpr mulexpr shiftexpr prefixexpr postfixexpr
%type <node> funclit seqlit tuplit name block stmt label use
-%type <node> declbody declcore structent arrayelt structelt tuphead
+%type <node> declbody declcore typedeclcore structent arrayelt structelt tuphead
%type <node> ifstmt forstmt whilestmt matchstmt elifs optexprln optexpr
%type <node> match
%type <node> castexpr
@@ -316,7 +316,11 @@ declbody: declcore Tasn expr {$$ = $1; $1->decl.init = $3;}
;
declcore: name {$$ = mkdecl($1->line, $1, mktyvar($1->line));}
- | name Tcolon type {$$ = mkdecl($1->line, $1, $3);}
+ | typedeclcore {$$ = $1;}
+ ;
+
+typedeclcore
+ : name Tcolon type {$$ = mkdecl($1->line, $1, $3);}
;
name : Tident {$$ = mkname($1->line, $1->str);}
@@ -441,13 +445,11 @@ compoundtype
functype: Toparen funcsig Tcparen {$$ = $2;}
;
-funcsig : argdefs
- {$$ = mktyfunc($1.line, $1.nl, $1.nn, mktyvar($1.line));}
- | argdefs Tret type
+funcsig : argdefs Tret type
{$$ = mktyfunc($1.line, $1.nl, $1.nn, $3);}
;
-argdefs : declcore {
+argdefs : typedeclcore {
$$.line = $1->line;
$$.nl = NULL;
$$.nn = 0; lappend(&$$.nl, &$$.nn, $1);
@@ -460,7 +462,7 @@ argdefs : declcore {
}
;
-tupledef: Tosqbrac typelist Tcsqbrac
+tupledef: Toparen typelist Tcparen
{$$ = mktytuple($1->line, $2.types, $2.ntypes);}
;
diff --git a/test/align.myr b/test/align.myr
index d1c976f..06555df 100644
--- a/test/align.myr
+++ b/test/align.myr
@@ -62,9 +62,9 @@ const main = {
std.put("size = %i\n", sizeof(alignstruct6))
std.put("size = %i\n", sizeof(alignstruct7))
/* size should be 8 */
- std.put("size = %i\n", sizeof([int, byte, byte]))
+ std.put("size = %i\n", sizeof((int, byte, byte)))
/* size should be 16 */
- std.put("size = %i\n", sizeof([int, byte, int, byte]))
+ std.put("size = %i\n", sizeof((int, byte, int, byte)))
/* size should be 12 */
- std.put("size = %i\n", sizeof([int, int, byte, byte]))
+ std.put("size = %i\n", sizeof((int, int, byte, byte)))
}