Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ let expr :=
| RETURN; lbl = expr_label; e = lhs; {
Return ((lbl,$startpos),e)
}
| MATCH; lbl = expr_label; e1 = lhs; WITH; NIL; ARROW; e2 = expr; BAR; CONS; h = ID; r = ID; ARROW; e3 = expr; {
| MATCH; lbl = expr_label; e1 = lhs; WITH; NIL; ARROW; e2 = expr; BAR; CONS; LPAREN; h = ID; COMMA; r = ID; RPAREN; ARROW; e3 = expr; {
Match ((lbl,$startpos),e1,e2,h,r,e3)
}

Expand Down Expand Up @@ -143,7 +143,7 @@ let op :=
| LPAREN; l = tuple_contents; RPAREN; <`Tuple>
| ~ = array_expr; <`Read>
| ~ = op; DOT; LENGTH; <`LengthOf>
| CONS; h = lhs; r = op; <`Cons>
| CONS; LPAREN; h = lhs; COMMA; r = op; RPAREN; <`Cons>
| NIL; { `Nil }

let tuple_rest :=
Expand Down
6 changes: 3 additions & 3 deletions src/test/list/easy/alias-cons2.imp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
insert_second(l, x) {
match l with
Nil -> ()
| Cons h r -> {
| Cons (h, r) -> {
let r2 = mkref *r in {
r := Cons x r2;
r := Cons (x, r2);
alias(l.Cons.2 = r)
}
}
}

{
let n = mkref Nil in
let l = Cons 0 n in {
let l = Cons (0, n) in {
insert_second(l, 1);
insert_second(l, 2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/list/easy/cons.imp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
let x = mkref Nil in
let y = mkref (Cons 1 x) in
let z = mkref (Cons 2 y) in
let y = mkref (Cons (1, x)) in
let z = mkref (Cons (2, y)) in
()
}
6 changes: 3 additions & 3 deletions src/test/list/easy/match-easy.imp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
let x = mkref Nil in
let y = mkref (Cons 1 x) in
let z = Cons 2 y in
let y = mkref (Cons (1, x)) in
let z = Cons (2, y) in
match z with
Nil -> ()
| Cons h r -> ()
| Cons (h, r) -> ()
}
8 changes: 4 additions & 4 deletions src/test/list/easy/match.imp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sum(l, s) {
match l with
Nil -> s
| Cons h r -> {
| Cons (h, r) -> {
let s2 = s + h in
let r2 = *r in {
alias(l.Cons.2 = r);
Expand All @@ -12,9 +12,9 @@ sum(l, s) {

{
let x = mkref Nil in
let y = mkref (Cons 1 x) in
let z = mkref (Cons 2 y) in
let l = Cons 3 z in
let y = mkref (Cons (1, x)) in
let z = mkref (Cons (2, y)) in
let l = Cons (3, z) in
let s = sum(l, 0) in
assert(s = 6)
}
6 changes: 3 additions & 3 deletions src/test/list/hd.imp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ mklist(n) {
let h = _ in
let m = n + -1 in
let t = mkref mklist(m) in
Cons h t
Cons (h, t)
}
}

hd(l) {
match l with
Nil -> fail
| Cons h t -> return h
| Cons (h, t) -> return h
}

{
let n = ( _ : ~ > 0) in
let l = mklist(n) in
match l with
Nil -> fail
| Cons h t -> assert(hd(l) = h)
| Cons (h, t) -> assert(hd(l) = h)
}
4 changes: 2 additions & 2 deletions src/test/list/length.imp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ mklist(n) {
let h = _ in
let m = n + -1 in
let t = mkref mklist(m) in
Cons h t
Cons (h, t)
}
}

len(l) {
match l with
Nil -> return 0
| Cons h t -> {
| Cons (h, t) -> {
let t_deref = *t in
let n = 1 + len(t_deref) in {
alias(t_deref = *t);
Expand Down
4 changes: 2 additions & 2 deletions src/test/list/nth.imp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ mklist(n) {
let h = _ in
let m = n + -1 in
let t = mkref mklist(m) in
Cons h t
Cons (h, t)
}
}

nth(l, n) {
match l with
Nil -> fail
| Cons h t -> {
| Cons (h, t) -> {
let m = n + -1 in
if n = 1 then h else nth(*t, m)
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/list/tl.imp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mklist(n) {
let h = _ in
let m = n + -1 in
let t = mkref mklist(m) in
Cons h t
Cons (h, t)
}
}

Expand All @@ -12,12 +12,12 @@ assert_eq(l1, l2) {
Nil -> {
match l2 with
Nil -> ()
| Cons h2 t2 -> fail
| Cons (h2, t2) -> fail
}
| Cons h1 t1 -> {
| Cons (h1, t1) -> {
match l2 with
Nil -> fail
| Cons h2 t2 -> {
| Cons (h2, t2) -> {
assert(h1 = h2);
let t1_deref = *t1 in
let t2_deref = *t2 in {
Expand All @@ -34,13 +34,13 @@ assert_eq(l1, l2) {
tl(l) {
match l with
Nil -> fail
| Cons h t -> return *t
| Cons (h, t) -> return *t
}

{
let n = ( _ : ~ > 0) in
let l = mklist(n) in
match l with
Nil -> fail
| Cons h t -> assert_eq(tl(l), *t)
| Cons (h, t) -> assert_eq(tl(l), *t)
}