X-Git-Url: https://git.danieliu.xyz/?p=ekitaihs.git;a=blobdiff_plain;f=Parse.hs;fp=Parse.hs;h=9b9de5796e499e98db6bca580773afa336fff4f2;hp=367caff6d151839d76090125d007648b46fada3c;hb=25cfe33daa0d0eb5ebfe9f8fad5d3a25aa098839;hpb=4de2980e358a4ed8bb05e615a3fee16215b03c1f diff --git a/Parse.hs b/Parse.hs index 367caff..9b9de57 100644 --- a/Parse.hs +++ b/Parse.hs @@ -1,8 +1,9 @@ -module Parse ( ekitaiOpts, optTimeStep ) where +module Parse ( ekitaiOpts, optTimeStep, hGetLines ) where import System.Console.GetOpt import System.Environment import System.Exit +import System.IO import Data.Maybe import Data.Either @@ -38,10 +39,13 @@ ekitaiOpts argv = (o, _, []) -> ioError $ userError $ "missing input file" (_, _, errs) -> ioError $ userError $ concat errs --- ++ usageInfo header options --- where header = "Usage: ekitai [OPTIONS...] simfile" +-- reads in file by lines +hGetLines :: Handle -> IO [String] +hGetLines h = do + line <- hGetLine h + isEof <- hIsEOF h + if isEof then return [line] + else do + lines <- hGetLines h + return (line:lines) - -- (o, _, []) -> do - -- opts <- (foldl (flip id) defaultOptions o) - -- if optHelp then userError $ concat usageInfo "Usage: ekitai [OPTIONS...] simfile" options - -- else ioError $ userError $ "missing input file"