forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |