ChildMessage.hs revision b87efd3db0d2dc41615ea28669faf80fc1b48d56
446N/A{- |
4744N/AModule : $Header$
446N/ADescription : get the output from a childProcess
446N/ACopyright : (c) Dominik Luecke, Uni Bremen 2007
446N/ALicense : GPLv2 or higher
446N/A
446N/AMaintainer : luecke@informatik.uni-bremen.de
446N/AStability : experimental
446N/APortability : portable
446N/A
446N/Aget the output from a childProcess
446N/A-}
446N/A
446N/Amodule Propositional.ChildMessage (parseIt) where
446N/A
446N/Aimport Common.UniUtils
446N/Aimport System.Exit
446N/A
446N/AparseIt :: ChildProcess -> (String -> Bool) -> IO String
446N/AparseIt cp isEnd = do
873N/A line <- readMsg cp
446N/A ls <- parseItHelp cp isEnd [line]
446N/A return $ unlines $ reverse ls
446N/A
446N/A-- | Helper function for parsing cp output
5073N/AparseItHelp :: ChildProcess -> (String -> Bool) -> [String] -> IO [String]
446N/AparseItHelp cp isEnd inT = do
446N/A e <- getToolStatus cp
446N/A case e of
4744N/A Just (ExitFailure _) -> return inT
4744N/A _ -> do
4744N/A line <- readMsg cp
4744N/A let out = line : inT
4744N/A if isEnd line then do
4744N/A waitForChildProcess cp
4744N/A return out
4744N/A else parseItHelp cp isEnd out
4744N/A