More verbose progress log, dump the result
authorunc0rr
Mon, 28 Nov 2011 17:57:25 +0400
changeset 6464 b78143e6f34e
parent 6462 0758fbec9b9f
child 6466 afd8c9a3672d
More verbose progress log, dump the result
tools/pas2c.hs
--- a/tools/pas2c.hs	Mon Nov 28 17:38:50 2011 +0100
+++ 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