-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ml
More file actions
53 lines (42 loc) · 2.1 KB
/
main.ml
File metadata and controls
53 lines (42 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
open Ll
open Arg
open Assert
open Driver
(* testing harness ---------------------------------------------------------- *)
exception Ran_tests
let suite = ref (Studenttests.provided_tests @ Gradedtests.graded_tests)
let slim_suite = ref (Studenttests.provided_tests @ Gradedtests.graded_tests)
let full_suite = ref (Studenttests.provided_tests @ Gradedtests.graded_tests @ Sharedtests.shared_suite)
let exec_tests (suite : suite ref) =
let o = run_suite !suite in
Printf.printf "%s\n" (outcome_to_string o);
raise Ran_tests
(* command-line arguments --------------------------------------------------- *)
let args =
[ ("--test", Unit (fun () -> exec_tests slim_suite), "run the test suite, ignoring other files inputs")
; ("--full-test", Unit (fun () -> exec_tests full_suite), "run the full test suite, ignoring other inputs")
; ("-op", Set_string Platform.output_path, "set the path to the output files directory [default='output']")
; ("-o", Set_string executable_filename, "set the name of the resulting executable [default='a.out']")
; ("-S", Clear assemble, "stop after generating .s files; do generate .o files")
; ("-c", Clear link, "stop after generating .o files; do not generate executables")
; ("--interpret-ll", Set interpret_ll, "runs each LL program through the LL interpreter")
; ("--print-ll", Set print_ll_flag, "prints the program LL code")
; ("--print-x86", Set print_x86_flag, "prints the program's assembly code")
; ("--clang", Set clang, "compiles to assembly using clang, not the compilerdesign backend")
; ("--execute-x86", Set execute_x86, "run the resulting executable file")
; ("-v", Unit Platform.enable_verbose, "enables more verbose compilation output")
]
(* Files found on the command line *)
let files = ref []
let main () =
Platform.configure_os ();
Platform.create_output_dir ();
try
Arg.parse args (fun filename -> files := filename :: !files)
"Compiler Design main test harness\n\
USAGE: ./main.native [options] <files>\n\
see README for details about using the compiler";
process_files !files
with Ran_tests ->
()
;; main ()