# HG changeset patch # User unc0rr # Date 1322488645 -14400 # Node ID d2b13364eddd8e088c130ad0cbfc0147030b39b6 # Parent 11c578d30bd31b59c85dfb17838a3e08dc5bb96f More verbose progress log, dump the result diff -r 11c578d30bd3 -r d2b13364eddd 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