aboutsummaryrefslogtreecommitdiff
path: root/main.ml
diff options
context:
space:
mode:
authorpacien2018-04-29 20:24:38 +0200
committerpacien2018-04-29 20:24:38 +0200
commit0647f37eebbefb8446fc8abfc533a23952fbb8be (patch)
treefc9d69f32bd6c04de27c3795f6d54ed150bd4958 /main.ml
parent80d7f0f204aacefa768d34f6db30108cb430cede (diff)
downloadurm-0647f37eebbefb8446fc8abfc533a23952fbb8be.tar.gz
Move sources to dedicated directory
Diffstat (limited to 'main.ml')
-rw-r--r--main.ml30
1 files changed, 0 insertions, 30 deletions
diff --git a/main.ml b/main.ml
deleted file mode 100644
index 2f8d57c..0000000
--- a/main.ml
+++ /dev/null
@@ -1,30 +0,0 @@
1(*
2 * UPEM / L3 / Functional programming / Project: URM
3 * Pacien TRAN-GIRARD, Adam NAILI
4 *)
5
6open Common
7open Parser
8open Instptr
9open Reg
10open Urm
11
12let exec_with_resource func filename =
13 let file = open_in filename in
14 let res = func file in
15 close_in file; res
16
17let read_prgm = exec_with_resource (fun f -> string_of_file f |> program_of_string)
18let read_regs = exec_with_resource (fun f -> string_of_file f |> regs_of_string)
19let run run_func prgm regs = urm_mk prgm regs |> run_func |> regs_string |> print_endline
20
21let run_mode_of_string = function
22 | "run" -> urm_run
23 | "trace" -> urm_run_trace
24 | _ -> failwith "Invalid run mode"
25
26let () = match Sys.argv with
27 | [| _; "run-tests" |] -> () (* handled in test files *)
28 | [| _; mode; prgm; regs |] -> run (run_mode_of_string mode) (read_prgm prgm) (read_regs regs)
29 | _ -> print_endline "Usage: urm <run-tests | run <prgmfile> <regfile> | trace <prgmfile> <regfile>>"
30