-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcompiler.sml
37 lines (35 loc) · 1.22 KB
/
compiler.sml
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
structure Compiler =
struct
open Util
open OS.Process
open Parser
infixr 0 $
fun main (prog_name, args : string list) : status =
let
val ast =
case args of
[] => (println "no input"; exit failure)
| _ => (parse_file (hd args))
val () = println "---- parsed."
val ty1 = ast ([], [], [], [], [])
val () = println "---- generated."
val ty2 = simplify_let_deriv $ cps_deriv ty1
val () = println "---- cpsed."
val () = println $ PlainPrinter.str_expr (#2 (extract_judge_typing ty2))
val ty3 = wrap_abs_deriv ty2
val () = println "---- wrapped."
val () = println $ PlainPrinter.str_expr (#2 (extract_judge_typing ty3))
val ty4 = simplify_let_deriv $ clo_conv_deriv ty3
val () = println "---- flattened."
val () = println $ PlainPrinter.str_expr (#2 (extract_judge_typing ty4))
val ty5 = hoist_deriv ty4
val () = check_program ty5
val () = println "---- hoisted."
val () = println $ str_program (#1 (extract_judge_ptyping ty5))
val ty6 = code_gen_deriv ty5
val () = println "---- coded."
val () = println $ str_tal_program (#1 (extract_judge_tal_program_typing ty6))
in
success
end
end