shithub: mc

Download patch

ref: e002242442a548429f014ec3a5c30f1d40799a7a
parent: 73d297264fae92c1e716f05e5f42496fad95dd37
author: Ori Bernstein <[email protected]>
date: Wed Jul 9 17:57:07 EDT 2014

Change syntax for tuples.

--- a/libstd/bigint.myr
+++ b/libstd/bigint.myr
@@ -37,7 +37,7 @@
 	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 @@
 }
 
 /* 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.
--- a/libstd/floatbits.myr
+++ b/libstd/floatbits.myr
@@ -3,8 +3,8 @@
 	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#))#}
--- a/libstd/optparse.myr
+++ b/libstd/optparse.myr
@@ -25,7 +25,7 @@
 	;;
 
 	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[:][:])
 ;;
--- a/libstd/utf.myr
+++ b/libstd/utf.myr
@@ -10,7 +10,7 @@
 	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
--- a/libstd/varargs.myr
+++ b/libstd/varargs.myr
@@ -4,7 +4,7 @@
 	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 @@
 	-> args castto(valist)
 }
 
-generic vanext = {ap -> [@a, valist]
+generic vanext = {ap -> (@a, valist)
 	var v : @a
 	var align
 	var p
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -139,7 +139,7 @@
 %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,8 +316,12 @@
         ;
 
 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);}
         | Tident Tdot name {$$ = $3; setns($3, $1->str);}
@@ -441,13 +445,11 @@
 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 @@
             }
         ;
 
-tupledef: Tosqbrac typelist Tcsqbrac
+tupledef: Toparen typelist Tcparen
             {$$ = mktytuple($1->line, $2.types, $2.ntypes);}
         ;
 
--- a/test/align.myr
+++ b/test/align.myr
@@ -62,9 +62,9 @@
 	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)))
 }