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