SCM Repository
[smlnj] Annotation of /sml/branches/gatien-branch/system/batchcomp.sml
Annotation of /sml/branches/gatien-branch/system/batchcomp.sml
Parent Directory
|
Revision Log
Revision 2162 -
(view)
(download)
Original Path: sml/trunk/system/batchcomp.sml
1 : |
blume |
515 |
local
|
2 : |
|
|
fun main _ = let
|
3 : |
|
|
fun quit () = OS.Process.exit OS.Process.success
|
4 : |
|
|
fun one [] = "ok"
|
5 : |
|
|
| one ["m"] = Bool.toString (CMB.make ())
|
6 : |
|
|
| one ["m", f] = Bool.toString (CMB.make' (SOME f))
|
7 : |
|
|
| one ["r"] = (CMB.reset (); "reset")
|
8 : |
|
|
| one ["?", v] =
|
9 : |
|
|
getOpt (Option.map Int.toString (#get (CMB.symval v) ()),
|
10 : |
|
|
"not set")
|
11 : |
blume |
733 |
| one ["=", v] = (#set (CMB.symval v) NONE; v ^ " set to NONE")
|
12 : |
blume |
515 |
| one ["=", v, n] =
|
13 : |
|
|
(case Int.fromString n of
|
14 : |
blume |
733 |
x as SOME _ => (#set (CMB.symval v) x; v ^ " set to " ^ n)
|
15 : |
blume |
515 |
| NONE => "bad number syntax")
|
16 : |
|
|
| one ["q"] = quit ()
|
17 : |
|
|
| one _ = "invalid command"
|
18 : |
|
|
fun loop () =
|
19 : |
|
|
case TextIO.inputLine TextIO.stdIn of
|
20 : |
|
|
"" => quit ()
|
21 : |
|
|
| line => (TextIO.output (TextIO.stdOut,
|
22 : |
|
|
one (String.tokens Char.isSpace line) ^
|
23 : |
|
|
"\n");
|
24 : |
|
|
loop ())
|
25 : |
|
|
in
|
26 : |
|
|
SMLofNJ.Internals.resetTimers ();
|
27 : |
|
|
Compiler.Stats.reset ();
|
28 : |
|
|
loop ()
|
29 : |
|
|
handle exn =>
|
30 : |
|
|
(TextIO.output (TextIO.stdOut,
|
31 : |
|
|
General.exnMessage exn ^ "\n");
|
32 : |
|
|
quit ())
|
33 : |
|
|
end
|
34 : |
|
|
in
|
35 : |
|
|
val _ = SMLofNJ.exportFn ("batchcomp", main)
|
36 : |
|
|
end
|