summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-02-04 23:00:27 -0800
committerOri Bernstein <ori@eigenstate.org>2017-02-04 23:00:27 -0800
commit545d75324d8ad1d9f8f9977b0911e8e9e0704674 (patch)
tree9be767627108edab0ce0833e5b5a308eaafc8ab0
parentd6bd40e37b085aec922c6bb56e867e85a6c36982 (diff)
downloadmc-545d75324d8ad1d9f8f9977b0911e8e9e0704674.tar.gz
Ucons are now prefix expressions.
It's just what it looks like. This cleans up taking the address of union literals.
-rw-r--r--doc/lang.txt5
-rw-r--r--lib/date/zoneinfo+posixy.myr2
-rw-r--r--lib/std/fltparse.myr8
-rw-r--r--lib/std/readall.myr2
-rw-r--r--lib/std/syswrap+posixy.myr2
-rw-r--r--lib/std/test/search.myr4
-rw-r--r--parse/gram.y16
-rw-r--r--test/exporttrait.myr1
8 files changed, 19 insertions, 21 deletions
diff --git a/doc/lang.txt b/doc/lang.txt
index 78b7b27..78f931d 100644
--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -1927,8 +1927,7 @@ TABLE OF CONTENTS:
expr: lorepxr asnop expr | lorexpr
lorexpr: lorexpr "||" landexpr | landexpr
landexpr: landexpr "&&" cmpexpr | cmpexpr
- cmpexpr: cmpexpr ("<" | "<=" | "==" | ">=" | ">") unionexpr | unionexpr
- unionexpr: "`" name unionexpr | "`" name | borexpr
+ cmpexpr: cmpexpr ("<" | "<=" | "==" | ">=" | ">") borexprexpr | borexpr
borexpr: borexpr ("|" | "^" ) bandexpr | bandexpr
bandexpr: bandexpr "&" addexpr | addexpr
addexpr: addexpr ("+" | "-") mulexpr
@@ -1942,8 +1941,10 @@ TABLE OF CONTENTS:
postexpr "++" | postexpr "--" |
postexpr "[" expr "]" |
postexpr "[" [expr] ":" [expr] "]" |
+ "`" name postexpr | "`" name
postepxr "#" |
atomicexpr
+
atomicexpr: ident | literal | "(" expr ")" | "sizeof" "(" type ")"
/* literals */
diff --git a/lib/date/zoneinfo+posixy.myr b/lib/date/zoneinfo+posixy.myr
index 76cb025..26aa916 100644
--- a/lib/date/zoneinfo+posixy.myr
+++ b/lib/date/zoneinfo+posixy.myr
@@ -71,7 +71,7 @@ const findtzoff = {tz, tm -> std.option(date.duration)
;;
ds = zone.ttinfo[zone.timetype[i]].gmtoff
free(zone)
- -> `std.Some (ds : date.duration) * 1_000_000
+ -> `std.Some ((ds : date.duration) * 1_000_000)
}
const load = {file
diff --git a/lib/std/fltparse.myr b/lib/std/fltparse.myr
index ff9a053..fcc97af 100644
--- a/lib/std/fltparse.myr
+++ b/lib/std/fltparse.myr
@@ -27,8 +27,8 @@ const flt64parse = {str
match fltparse(str)
| `Badflt: -> `std.None
- | `Inf sign: -> `std.Some (sign : flt64) * std.flt64inf()
- | `Nan sign: -> `std.Some (sign : flt64) * std.flt64nan()
+ | `Inf sign: -> `std.Some ((sign : flt64) * std.flt64inf())
+ | `Nan sign: -> `std.Some ((sign : flt64) * std.flt64nan())
| `Flt (sign, mant, exp):
val = toflt(sign, mant, exp, &lim64)
std.bigfree(mant)
@@ -41,8 +41,8 @@ const flt32parse = {str
match fltparse(str)
| `Badflt: -> `std.None
- | `Inf sign: -> `std.Some (sign : flt32) * std.flt32inf()
- | `Nan sign: -> `std.Some (sign : flt32) * std.flt32nan()
+ | `Inf sign: -> `std.Some ((sign : flt32) * std.flt32inf())
+ | `Nan sign: -> `std.Some ((sign : flt32) * std.flt32nan())
| `Flt (sign, mant, exp):
val = toflt(sign, mant, exp, &lim32)
std.bigfree(mant)
diff --git a/lib/std/readall.myr b/lib/std/readall.myr
index 68c930e..4f7d1da 100644
--- a/lib/std/readall.myr
+++ b/lib/std/readall.myr
@@ -22,5 +22,5 @@ const readall = {fd, dst
-> `Err e
;;
;;
- -> `Ok sz - dst.len
+ -> `Ok (sz - dst.len)
}
diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr
index 2e8474d..e930e0f 100644
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -156,7 +156,7 @@ const fmtime = {path
if r >= 0
sec = (sb.mtime.sec : time)
nsec = (sb.mtime.nsec : time)
- -> `Ok sec*1000 + nsec/1_000_000
+ -> `Ok (sec*1000 + nsec/1_000_000)
else
-> check(r)
;;
diff --git a/lib/std/test/search.myr b/lib/std/test/search.myr
index eea3680..31e1e63 100644
--- a/lib/std/test/search.myr
+++ b/lib/std/test/search.myr
@@ -5,13 +5,13 @@ const sl = [1, 3, 5, 8, 9, 33]
const main = {
expect(std.lsearch(sl[:], 1, std.numcmp), `std.Some 0)
- expect(std.lsearch(sl[:], 33, std.numcmp), `std.Some sl.len - 1)
+ expect(std.lsearch(sl[:], 33, std.numcmp), `std.Some (sl.len - 1))
expect(std.lsearch(sl[:], 5, std.numcmp), `std.Some 2)
expect(std.lsearch(sl[:], 6, std.numcmp), `std.None)
expect(std.lsearch(sl[:0], 6, std.numcmp), `std.None)
expect(std.bsearch(sl[:], 1, std.numcmp), `std.Some 0)
- expect(std.bsearch(sl[:], 33, std.numcmp), `std.Some sl.len - 1)
+ expect(std.bsearch(sl[:], 33, std.numcmp), `std.Some (sl.len - 1))
expect(std.bsearch(sl[:], 5, std.numcmp), `std.Some 2)
expect(std.bsearch(sl[:], 6, std.numcmp), `std.None)
expect(std.bsearch(sl[:0], 1, std.numcmp), `std.None) /* empty slice */
diff --git a/parse/gram.y b/parse/gram.y
index 10f2843..67edb24 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -140,7 +140,7 @@ static void setupinit(Node *n);
%type<node> exprln retexpr goto continue break expr atomicexpr
%type<node> littok literal lorexpr landexpr borexpr strlit bandexpr
-%type<node> cmpexpr unionexpr addexpr mulexpr shiftexpr prefixexpr
+%type<node> cmpexpr addexpr mulexpr shiftexpr prefixexpr
%type<node> postfixexpr funclit seqlit tuplit name block stmt label
%type<node> use fnparam declbody declcore typedeclcore structent
%type<node> arrayelt structelt tuphead ifstmt forstmt whilestmt
@@ -384,7 +384,7 @@ implbody
}
;
-traitdef: Ttrait Tident generictype optauxtypes Tendln { /* trait prototype */
+traitdef: Ttrait Tident generictype optauxtypes { /* trait prototype */
$$ = mktrait($1->loc,
mkname($2->loc, $2->id), $3,
$4.types, $4.ntypes,
@@ -639,19 +639,13 @@ landexpr: landexpr Tland cmpexpr
| cmpexpr
;
-cmpexpr : cmpexpr cmpop unionexpr
+cmpexpr : cmpexpr cmpop borexpr
{$$ = mkexpr($1->loc, binop($2->type), $1, $3, NULL);}
- | unionexpr
+ | borexpr
;
cmpop : Teq | Tgt | Tlt | Tge | Tle | Tne ;
-unionexpr
- : Ttick name unionexpr {$$ = mkexpr($1->loc, Oucon, $2, $3, NULL);}
- | Ttick name {$$ = mkexpr($1->loc, Oucon, $2, NULL);}
- | borexpr
- ;
-
borexpr : borexpr Tbor bandexpr
{$$ = mkexpr($1->loc, binop($2->type), $1, $3, NULL);}
@@ -696,6 +690,8 @@ prefixexpr
| Tbnot prefixexpr {$$ = mkexpr($1->loc, Obnot, $2, NULL);}
| Tminus prefixexpr {$$ = mkexpr($1->loc, Oneg, $2, NULL);}
| Tplus prefixexpr {$$ = $2;} /* positive is a nop */
+ | Ttick name prefixexpr {$$ = mkexpr($1->loc, Oucon, $2, $3, NULL);}
+ | Ttick name {$$ = mkexpr($1->loc, Oucon, $2, NULL);}
| postfixexpr
;
diff --git a/test/exporttrait.myr b/test/exporttrait.myr
index e373350..f415520 100644
--- a/test/exporttrait.myr
+++ b/test/exporttrait.myr
@@ -2,6 +2,7 @@ use std
pkg =
trait t @a
+
impl t int
;;