packages feed

Hs2lib-0.5.7: Hs2lib-debug.hs

-----------------------------------------------------------------------------
-- |
-- Module      :  Windll
-- Copyright   :  (c) Tamar Christina 2009 - 2010
-- License     :  BSD3
-- 
-- Maintainer  :  tamar@zhox.com
-- Stability   :  experimental
-- Portability :  portable
--
-- The main entry file for the preprocessor
-- part of the WinDll suite
--
-----------------------------------------------------------------------------

module Main where

import WinDll.CmdArgs.Debug
import WinDll.Session.Debug
import WinDll.Parsers.Debug
import WinDll.Debug.Output
import WinDll.Utils.Feedback

import System.Info
import Control.Monad.State.Strict
import Control.Monad.Error

-- | Determine the platform we're currently running on, so we can tweak the defaults a bit
mode :: Platform
mode = case os of
         "mingw32" -> Windows
         _         -> Unix
         
main = goArgs mode bootstrap

-- | Get the ball rolling on everything
bootstrap :: Config -> IO ()
bootstrap cfg = 
 do val <- runErrorT (evalStateT mainStart cfg)
    case val of
      (Left str) -> fail ("Program returned error in computation: '" ++ str ++ "'")
      (Right  _) -> return ()

-- | Start of the main computation
mainStart :: Exec ()
mainStart = do  inform _normal "Program starting up..." 
                discoverFiles 
                loadAndParse
                
                -- These lines do all the needed calculations
                result <- analyze
                displayResults result
                
                -- clean up
                cleanup
                
                inform _detail "Program terminating..."
                liftIO $ putStrLn "Done."