diff --git a/Interpreter.hs b/Interpreter.hs index ec36d026de26741a7462a7fe658c655b94b6af0e..06709a9be2df7843c658db127f6c1fe9187266ee 100644 --- a/Interpreter.hs +++ b/Interpreter.hs @@ -2,6 +2,7 @@ import Types import Debug import Eval import System.IO +import ReadCSV parse :: String -> Program parse = notImplemented @@ -34,10 +35,6 @@ evalFinal = evalFull [] showFinal :: Expr -> IO () showFinal = notImplemented - --------------------------------------------- - - -------------------------------------------- loadInputFile :: SymbolName -> IO Expr loadInputFile name = do @@ -46,8 +43,12 @@ loadInputFile name = do return output where - toRecord stringList = Record $ map String stringList + toRecord stringList = Record $ map ((String).stripLeadingAndTrailingWhitespace) stringList + +stripLeadingAndTrailingWhitespace = stripTrailingWhitespace.dropWhile (==' ') +stripTrailingWhitespace (' ':xs) = let remainder = stripTrailingWhitespace xs in + if null remainder then [] else ' ':remainder -readCSV :: FilePath -> IO [[String]] -readCSV = notImplemented \ No newline at end of file +stripTrailingWhitespace (x:xs) = x : stripTrailingWhitespace xs +stripTrailingWhitespace [] = []