diff --git a/regression/test060.lama b/regression/test060.lama index 82b131056..7b4069731 100644 --- a/regression/test060.lama +++ b/regression/test060.lama @@ -13,7 +13,7 @@ fun f (l) { local x = read (); write (f ({})); -write (f ({1})); +write (f (1:{})); write (f ({1, 1})); write (f ({1, 1, 1})); write (f ({1, 2, 1})) diff --git a/regression/test092.lama b/regression/test092.lama index 2b85c8504..3d4495b8a 100644 --- a/regression/test092.lama +++ b/regression/test092.lama @@ -13,7 +13,7 @@ fun f (l) { local x = read (); write (f ({})); -write (f ({1})); +write (f (1:{})); write (f ({1, 1})); write (f ({1, 1, 1})); write (f ({1, 2, 1})) diff --git a/src/Language.ml b/src/Language.ml index 77547faac..64a8b6907 100644 --- a/src/Language.ml +++ b/src/Language.ml @@ -312,8 +312,8 @@ module Pattern = | t:UIDENT ps:(-"(" !(Util.list)[parse] -")")? {Sexp (t, match ps with None -> [] | Some ps -> ps)} | "[" ps:(!(Util.list0)[parse]) "]" {Array ps} | "{" ps:(!(Util.list0)[parse]) "}" {match ps with - | [] -> UnBoxed - | _ -> List.fold_right (fun x acc -> Sexp ("cons", [x; acc])) ps UnBoxed + | [] -> Const 0 + | _ -> List.fold_right (fun x acc -> Sexp ("cons", [x; acc])) ps (Const 0) } | l:$ x:LIDENT y:(-"@" parse)? {Loc.attach x l#coord; match y with None -> Named (x, Wildcard) | Some y -> Named (x, y)} | s:("-")? c:DECIMAL {Const (match s with None -> c | _ -> ~-c)} @@ -709,10 +709,6 @@ module Expr = let name = infix_name s in Loc.attach name l#coord; ignore atr (Var name) ) } - (* - | l:$ %"fun" "(" args:!(Util.list0)[ostap (l:$ x:LIDENT {Loc.attach x l#coord; x})] ")" - "{" body:scope[infix][Weak] "}"=> {notRef atr} :: (not_a_reference l) => {ignore atr (Lambda (args, body))} - *) | l:$ %"fun" "(" args:!(Util.list0)[Pattern.parse] ")" "{" body:scope[infix][Weak] "}"=> {notRef atr} :: (not_a_reference l) => { let args, body = diff --git a/src/SM.ml b/src/SM.ml index 652524357..690530551 100644 --- a/src/SM.ml +++ b/src/SM.ml @@ -101,9 +101,19 @@ let rec eval env (((cstack, stack, glob, loc, i, o) as conf) : config) = functio Printf.eprintf " insn=%s\n" (show_insn insn); Printf.eprintf " stack=%s\n" (show(list) (show(value)) stack); Printf.eprintf "end\n"; - *) + *) (match insn with | PUBLIC _ | EXTERN _ -> eval env conf prg' + | BINOP "==" -> let y::x::stack' = stack in + let z = + match x, y with + | Value.Int _, Value.Int _ -> Value.of_int @@ Expr.to_func "==" (Value.to_int x) (Value.to_int y) + | Value.Int _, _ | _, Value.Int _ -> Value.of_int 0 + | _ -> failwith "unexpected operands in comparison: %s vs. %s\n" + (show(Value.t) (fun _ -> "") (fun _ -> "") x) + (show(Value.t) (fun _ -> "") (fun _ -> "") y) + in + eval env (cstack, z :: stack', glob, loc, i, o) prg' | BINOP op -> let y::x::stack' = stack in eval env (cstack, (Value.of_int @@ Expr.to_func op (Value.to_int x) (Value.to_int y)) :: stack', glob, loc, i, o) prg' | CONST n -> eval env (cstack, (Value.of_int n)::stack, glob, loc, i, o) prg' | STRING s -> eval env (cstack, (Value.of_string @@ Bytes.of_string s)::stack, glob, loc, i, o) prg' diff --git a/src/version.ml b/src/version.ml index 3640c3944..22db40b80 100644 --- a/src/version.ml +++ b/src/version.ml @@ -1 +1 @@ -let version = "Version 1.00, fe5a9321, Sun Feb 23 01:48:49 2020 +0300" +let version = "Version 1.00, 3e2c87d4, Sun Feb 23 22:15:27 2020 +0300" diff --git a/stdlib/List.lama b/stdlib/List.lama index 0804522f5..c2dc5143f 100644 --- a/stdlib/List.lama +++ b/stdlib/List.lama @@ -79,13 +79,13 @@ public fun flatten (l) { fun append (x) { local new = x : {}; - + curr [0][1] := new; curr [0] := new } - + iter (fun (x) {iter (append, x)}, l); - + res [1] } diff --git a/stdlib/regression/test07.lama b/stdlib/regression/test07.lama index e637cda5a..b303630c7 100644 --- a/stdlib/regression/test07.lama +++ b/stdlib/regression/test07.lama @@ -3,11 +3,11 @@ import Collection; local a = {1, 2, 3}, b = {1, 2, 3}, t = emptyHashTab (); t := addHashTab (t, a, 100); -validateColl (); +validateColl (t); printf ("HashTab internal structure: %s\n", t.string); t := addHashTab (t, b, 200); -validateColl (); +validateColl (t); printf ("HashTab internal structure: %s\n", t.string); printf ("Searching: %s\n", findHashTab (t, a).string);