36 |
val _ = checkForErrors errStrm |
val _ = checkForErrors errStrm |
37 |
val ast = (checkTypes pt) handle Typechecker.Error => AST.Program[] |
val ast = (checkTypes pt) handle Typechecker.Error => AST.Program[] |
38 |
val _ = checkForErrors errStrm |
val _ = checkForErrors errStrm |
39 |
val _ = ASTPP.output (TextIO.stdOut, ast) (* DEBUG *) |
val _ = ASTPP.output (Log.logFile(), ast) (* DEBUG *) |
40 |
val simple = Simplify.transform ast |
val simple = Simplify.transform ast |
41 |
val _ = SimplePP.output (TextIO.stdOut, simple) |
val _ = SimplePP.output (Log.logFile(), simple) |
42 |
val highIL = Translate.translate simple |
val highIL = Translate.translate simple |
43 |
in |
in |
44 |
() |
() |
47 |
TextIO.closeIn inS |
TextIO.closeIn inS |
48 |
end |
end |
49 |
|
|
50 |
fun main (name: string, args: string list) = |
fun doOptions args = let |
51 |
if Inputs.initFromArgs args |
val log = ref false |
52 |
then |
val defs = ref [] |
53 |
(List.app doFile args; OS.Process.success) |
fun doOpts [file] = {log = !log, defs = !defs, file = file} |
54 |
|
| doOpts ("-log"::r) = (log := true; doOpts r) |
55 |
|
| doOpts (opt::r) = (defs := opt :: !defs; doOpts r) |
56 |
|
in |
57 |
|
doOpts args |
58 |
|
end |
59 |
|
|
60 |
|
fun main (name: string, args: string list) = let |
61 |
|
val {log, defs, file} = doOptions args |
62 |
|
val {base, ...} = OS.Path.splitBaseExt file |
63 |
|
in |
64 |
|
if Inputs.initFromArgs defs |
65 |
|
then (Log.init(base ^ ".log"); doFile file; OS.Process.success) |
66 |
handle exn => ( |
handle exn => ( |
67 |
err (concat [ |
err (concat [ |
68 |
"uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]); |
"uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]); |
70 |
(SMLofNJ.exnHistory exn); |
(SMLofNJ.exnHistory exn); |
71 |
quitWithError()) |
quitWithError()) |
72 |
else (err "invalid command-line inputs\n"; quitWithError()) |
else (err "invalid command-line inputs\n"; quitWithError()) |
73 |
|
end |
74 |
|
|
75 |
fun test file = (main ("", [file]); print "** Success!!\n") |
fun test file = (main ("", [file]); print "** Success!!\n") |
76 |
|
|