diff --git a/src/parser.mly b/src/parser.mly index 41db0a75..7f31abe9 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -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) } @@ -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 := diff --git a/src/test/list/easy/alias-cons2.imp b/src/test/list/easy/alias-cons2.imp index a2eb3e6a..6356f753 100644 --- a/src/test/list/easy/alias-cons2.imp +++ b/src/test/list/easy/alias-cons2.imp @@ -1,9 +1,9 @@ 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) } } @@ -11,7 +11,7 @@ insert_second(l, x) { { 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); } diff --git a/src/test/list/easy/cons.imp b/src/test/list/easy/cons.imp index 0b96548b..010ed7db 100644 --- a/src/test/list/easy/cons.imp +++ b/src/test/list/easy/cons.imp @@ -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 () } \ No newline at end of file diff --git a/src/test/list/easy/match-easy.imp b/src/test/list/easy/match-easy.imp index 0aaaf3ea..a9996ed7 100644 --- a/src/test/list/easy/match-easy.imp +++ b/src/test/list/easy/match-easy.imp @@ -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) -> () } \ No newline at end of file diff --git a/src/test/list/easy/match.imp b/src/test/list/easy/match.imp index 3bbdb506..ee0f6590 100644 --- a/src/test/list/easy/match.imp +++ b/src/test/list/easy/match.imp @@ -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); @@ -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) } \ No newline at end of file diff --git a/src/test/list/hd.imp b/src/test/list/hd.imp index 08f77b09..1d7bcbcb 100644 --- a/src/test/list/hd.imp +++ b/src/test/list/hd.imp @@ -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) } } hd(l) { match l with Nil -> fail - | Cons h t -> return h + | Cons (h, t) -> return h } { @@ -18,5 +18,5 @@ hd(l) { let l = mklist(n) in match l with Nil -> fail - | Cons h t -> assert(hd(l) = h) + | Cons (h, t) -> assert(hd(l) = h) } \ No newline at end of file diff --git a/src/test/list/length.imp b/src/test/list/length.imp index 85b19d2c..99b6d25e 100644 --- a/src/test/list/length.imp +++ b/src/test/list/length.imp @@ -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); diff --git a/src/test/list/nth.imp b/src/test/list/nth.imp index 6ba96e1e..7ec91257 100644 --- a/src/test/list/nth.imp +++ b/src/test/list/nth.imp @@ -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) } diff --git a/src/test/list/tl.imp b/src/test/list/tl.imp index 31c5060c..95ec8998 100644 --- a/src/test/list/tl.imp +++ b/src/test/list/tl.imp @@ -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) } } @@ -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 { @@ -34,7 +34,7 @@ assert_eq(l1, l2) { tl(l) { match l with Nil -> fail - | Cons h t -> return *t + | Cons (h, t) -> return *t } { @@ -42,5 +42,5 @@ tl(l) { 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) } \ No newline at end of file