diff src/main.mlton.sml @ 208:63a2f2322c1f

-timing option for command-line compiler
author Adam Chlipala <adamc@hcoop.net>
date Sat, 16 Aug 2008 10:54:46 -0400
parents 8921f0344193
children 8bb46d87b074
line wrap: on
line diff
--- a/src/main.mlton.sml	Thu Aug 14 18:35:08 2008 -0400
+++ b/src/main.mlton.sml	Sat Aug 16 10:54:46 2008 -0400
@@ -25,4 +25,26 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *)
 
-val () = Compiler.compile (CommandLine.arguments ())
+fun doArgs (args, (timing, sources)) =
+    case args of
+        [] => (timing, rev sources)
+      | arg :: rest =>
+        let
+            val acc =
+                if size arg > 0 andalso String.sub (arg, 0) = #"-" then
+                    case arg of
+                        "-timing" => (true, sources)
+                      | _ => raise Fail ("Unknown option " ^ arg)
+                else
+                    (timing, arg :: sources)
+        in
+            doArgs (rest, acc)
+        end
+
+val (timing, sources) = doArgs (CommandLine.arguments (), (false, []))
+
+val () =
+    if timing then
+        Compiler.time Compiler.toCjrize sources
+    else
+        Compiler.compile sources