Skip to content

Commit

Permalink
run mochi automatically (may error occurs)
Browse files Browse the repository at this point in the history
  • Loading branch information
artoy committed Nov 6, 2023
1 parent ee5a3c4 commit b6a043c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ paper/related_work.tex
paper/semantics.tex
paper/typesystem.tex
paper/wf_rules.tex
src/test/to_mochi.ml
8 changes: 5 additions & 3 deletions src/callMoCHi.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
let call_mochi =
let cmd = "~/git/MoCHi/src.mochi.exe ./test/to_mochi.ml" in
let proc = Process.spawn cmd in

let cmd = "~/git/MoCHi/src/mochi.exe ./test/to_mochi.ml" in
let p = Process.spawn cmd in
let res = (String.trim @@ input_line p.Process.proc_stdout, String.trim @@ input_line p.Process.proc_stderr) in
Process.dispose p;
res
8 changes: 7 additions & 1 deletion src/consort.ml
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,11 @@ let convmochi ~opts file =
((function Some x -> x | None -> assert false) ownership_res)
ast
in
ConvMoCHi.Mochi.print_prog prog;
(* ConvMoCHi.Mochi.print_prog prog; *)
let file = open_out "./test/to_mochi.ml" in
ConvMoCHi.Mochi.write_to_channel_prog prog file;
Out_channel.close file;
let (res_out, res_err) = CallMoCHi.call_mochi in
print_endline res_out;
print_endline res_err;
match ownership_res with None -> Unverified Aliasing | Some _ -> Verified
4 changes: 4 additions & 0 deletions src/convMoCHi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ module Mochi = struct
let print_prog prog =
print_endline builtin;
pp_prog prog std_formatter

let write_to_channel_prog prog file =
Printf.fprintf file "%s\n" builtin;
pp_prog prog (Format.formatter_of_out_channel file);
end

let pull_type ty con i =
Expand Down

0 comments on commit b6a043c

Please sign in to comment.