More verbose progress log, dump the result
authorunc0rr
Mon, 28 Nov 2011 17:57:25 +0400
changeset 6455 d2b13364eddd
parent 6453 11c578d30bd3
child 6457 ef16d50d598e
More verbose progress log, dump the result
tools/pas2c.hs
--- a/tools/pas2c.hs	Sun Nov 27 23:13:22 2011 +0300
+++ b/tools/pas2c.hs	Mon Nov 28 17:57:25 2011 +0400
@@ -18,23 +18,26 @@
 pas2C :: String -> IO ()
 pas2C fn = do
     setCurrentDirectory "../hedgewars/"
-    flip evalStateT initState $ f fn
+    s <- flip execStateT initState $ f fn
+    writeFile "dump" $ show s
     where
     printLn = liftIO . hPutStrLn stderr
+    print = liftIO . hPutStr stderr
     initState = Map.empty
     f :: String -> StateT (Map.Map String PascalUnit) IO ()
     f fileName = do
         processed <- gets $ Map.member fileName
         unless processed $ do
+            print ("Preprocessing '" ++ fileName ++ ".pas'... ")
             fc' <- liftIO 
                 $ tryJust (guard . isDoesNotExistError) 
-                $ hPutStr stderr ("Preprocessing '" ++ fileName ++ ".pas'... ") >> preprocess (fileName ++ ".pas")
+                $ preprocess (fileName ++ ".pas")
             case fc' of
                 (Left a) -> do
                     modify (Map.insert fileName System)
                     printLn "doesn't exist"
                 (Right fc) -> do
-                    printLn "ok"
+                    print "ok, parsing... "
                     let ptree = parse pascalUnit fileName fc
                     case ptree of
                          (Left a) -> do
@@ -42,10 +45,11 @@
                             printLn $ show a ++ "\nsee preprocess.out for preprocessed source"
                             fail "stop"
                          (Right a) -> do
+                            printLn "ok"
                             modify (Map.insert fileName a)
                             mapM_ f (usesFiles a)
-                            
-         
+
+
 usesFiles :: PascalUnit -> [String]         
 usesFiles (Program _ (Implementation uses _) _) = uses2List uses
 usesFiles (Unit _ (Interface uses1 _) (Implementation uses2 _) _ _) = uses2List uses1 ++ uses2List uses2