From 95039ff486f59eab135c18c8328ee4601ddc339b Mon Sep 17 00:00:00 2001 From: Marek Bernat Date: Mon, 18 Nov 2019 19:01:08 +0100 Subject: [PATCH] Add toplevel loading script --- toplevel/dune | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 toplevel/dune diff --git a/toplevel/dune b/toplevel/dune new file mode 100644 index 000000000000..3776bce1848e --- /dev/null +++ b/toplevel/dune @@ -0,0 +1,24 @@ +let run_and_get_lines cmd = + let inp = Unix.open_process_in cmd in + let res = ref [] in + let () = try + while true do + let line = input_line inp in + res := List.cons line !res + done + with End_of_file -> + close_in inp + in + List.rev(!res) +in +let exec s = + let l = Lexing.from_string s in + let ph = !Toploop.parse_toplevel_phrase l in + let fmt = Format.make_formatter (fun _ _ _ -> ()) (fun _ -> ()) in + try + let _ = Toploop.execute_phrase false fmt ph in () + with + _ -> () +in +let lines = run_and_get_lines "./dune.exe toplevel-init-file" in +List.iter (fun l -> exec l) lines \ No newline at end of file