mirror of
https://github.com/kanaka/mal.git
synced 2024-09-20 01:57:09 +03:00
ocaml: Clearer top-level exception handling
This commit is contained in:
parent
044eb1c758
commit
19950b9f1d
@ -138,7 +138,12 @@ let rec main =
|
||||
ignore (rep "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))" repl_env);
|
||||
|
||||
if Array.length Sys.argv > 1 then
|
||||
ignore (rep ("(load-file \"" ^ Sys.argv.(1) ^ "\")") repl_env)
|
||||
try
|
||||
ignore (rep ("(load-file \"" ^ Sys.argv.(1) ^ "\")") repl_env);
|
||||
with
|
||||
| Types.MalExn exc ->
|
||||
output_string stderr ("Exception: " ^ (print exc) ^ "\n");
|
||||
flush stderr
|
||||
else
|
||||
while true do
|
||||
print_string "user> ";
|
||||
@ -146,6 +151,9 @@ let rec main =
|
||||
try
|
||||
print_endline (rep line repl_env);
|
||||
with End_of_file -> ()
|
||||
| Types.MalExn exc ->
|
||||
output_string stderr ("Exception: " ^ (print exc) ^ "\n");
|
||||
flush stderr
|
||||
| Invalid_argument x ->
|
||||
output_string stderr ("Invalid_argument exception: " ^ x ^ "\n");
|
||||
flush stderr
|
||||
|
@ -141,7 +141,12 @@ let rec main =
|
||||
ignore (rep "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))" repl_env);
|
||||
|
||||
if Array.length Sys.argv > 1 then
|
||||
ignore (rep ("(load-file \"" ^ Sys.argv.(1) ^ "\")") repl_env)
|
||||
try
|
||||
ignore (rep ("(load-file \"" ^ Sys.argv.(1) ^ "\")") repl_env);
|
||||
with
|
||||
| Types.MalExn exc ->
|
||||
output_string stderr ("Exception: " ^ (print exc) ^ "\n");
|
||||
flush stderr
|
||||
else begin
|
||||
ignore (rep "(println (str \"Mal [\" *host-language* \"]\"))" repl_env);
|
||||
while true do
|
||||
@ -150,6 +155,9 @@ let rec main =
|
||||
try
|
||||
print_endline (rep line repl_env);
|
||||
with End_of_file -> ()
|
||||
| Types.MalExn exc ->
|
||||
output_string stderr ("Exception: " ^ (print exc) ^ "\n");
|
||||
flush stderr
|
||||
| Invalid_argument x ->
|
||||
output_string stderr ("Invalid_argument exception: " ^ x ^ "\n");
|
||||
flush stderr
|
||||
|
Loading…
Reference in New Issue
Block a user