[add -C option to compile to C and stop, and --stop option to stop after various phases
John Meacham <john@repetae.net>**20100723131607
 Ignore-this: 24afd76721db448a64700c3edc0a056e
] hunk ./src/Grin/Main.hs 83
-compileGrinToC grin | optMode options /= CompileExe = return ()
hunk ./src/Grin/Main.hs 86
-        cf = (fn ++ "_code.c")
+        cf = case (optOutName options,optMode options) of
+            (Just fn,StopC) -> fn
+            _ -> (fn ++ "_code.c")
hunk ./src/Grin/Main.hs 103
+    when (optMode options == StopC) $
+        exitSuccess
hunk ./src/Ho/Build.hs 409
+    when (optMode options == StopParse) $
+        exitSuccess
hunk ./src/Ho/Build.hs 415
+    when (optMode options  == StopTypeCheck) $
+        exitSuccess
hunk ./src/Main.hs 3
+import System.Exit
+import System.IO
hunk ./src/Main.hs 7
-import IO(hFlush,stderr)
hunk ./src/Main.hs 46
+        StopError s     -> putErrLn "bad option passed to --stop should be one of parse, typecheck, or c" >> exitWith exitCodeUsage 
hunk ./src/Main.hs 49
-        Preprocess      -> forM_ (optArgs o) $ \fn -> do
-            LBS.readFile fn >>= preprocess fn >>= LBS.putStr
-        _               -> darg >> processFiles  (optArgs o)
+        Preprocess      -> do
+            forM_ (optArgs o) $ \fn -> do
+                LBS.readFile fn >>= preprocess fn >>= LBS.putStr
+        _               -> darg >> processFiles (optArgs o)
hunk ./src/Main.hs 54
+exitCodeUsage = ExitFailure 64
hunk ./src/Options.hs 142
+          | StopError String         -- ^ error
+          | StopParse                -- ^ Just parse and rename modules then exit
+          | StopTypeCheck            -- ^ Stop after type checking
hunk ./src/Options.hs 146
-          | CompileHoGrin            -- ^ Compile ho and grin
+          | StopC                    -- ^ Stop after producing C code.
hunk ./src/Options.hs 241
-    , Option ['N'] ["noprelude"] (NoArg  (optPrelude_s False))         "no implicit prelude"
-    , Option ['c'] []            (NoArg  (optMode_s CompileHo))        "Typecheck and compile module"
+    , Option ['N'] ["noprelude"] (NoArg  (optPrelude_s False))         "do not automatically import the prelude"
+    , Option ['c'] []            (NoArg  (optMode_s CompileHo))        "just compile the modules, caching the results."
+    , Option ['C'] []            (NoArg  (optMode_s StopC))            "compile to C code"
hunk ./src/Options.hs 247
+    , Option []    ["stop"]      (ReqArg (optMode_s . stop) "parse/typecheck/c")  "stop after the given pass, parse/typecheck/c"
hunk ./src/Options.hs 252
-    , Option ['e'] []            (ReqArg (\d -> optStmts_u (d:)) "<statement>")  "run given statement as if on jhci prompt"
+--    , Option ['e'] []            (ReqArg (\d -> optStmts_u (d:)) "<statement>")  "run given statement as if on jhci prompt"
hunk ./src/Options.hs 260
-    , Option []    ["interactive"] (NoArg  (optMode_s Interactive))    "run interactivly"
+    , Option []    ["interactive"] (NoArg  (optMode_s Interactive))    "run interactivly (for debugging only)"
hunk ./src/Options.hs 271
+stop "parse" = StopParse
+stop "deps" = StopParse
+stop "typecheck" = StopTypeCheck
+stop "c" = StopC
+stop s = StopError s
+
+