Skip to content

Commit

Permalink
Add toplevel loading script
Browse files Browse the repository at this point in the history
  • Loading branch information
mbernat committed Nov 18, 2019
1 parent f2d1c8a commit 95039ff
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions toplevel/dune
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 95039ff

Please sign in to comment.