From 4b5442992c624b239602346da177718d8b8832fb Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sun, 31 Aug 2014 21:30:11 +1000 Subject: Removed arbitrary file handling from getc/putc until more monads are in place --- src/Grasp/Interpreter.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/Grasp') diff --git a/src/Grasp/Interpreter.hs b/src/Grasp/Interpreter.hs index d719527..a8ce18a 100644 --- a/src/Grasp/Interpreter.hs +++ b/src/Grasp/Interpreter.hs @@ -418,16 +418,16 @@ getcI g node = do fhL = targetLabels g (getByLabel "fh" edges) c <- case fhL of - x | length x == 0 -> getChar >>= + x | length x == 0 || length x == 1 -> getChar >>= (\x -> if (x == '\EOT') then return (-1) else return (ord x)) - x | length x == 1 -> do - h <- openFile (head fhL) ReadMode - input <- try (hGetChar h) - hClose h - case input of - Left e -> if (isEOFError e) then return (-1) else ioError e - Right inpChr -> return (ord inpChr) + --x | length x == 1 -> do + -- h <- openFile (head fhL) ReadMode + -- input <- try (hGetChar h) + -- hClose h + -- case input of + -- Left e -> if (isEOFError e) then return (-1) else ioError e + -- Right inpChr -> return (ord inpChr) x -> error ("Instruction " ++ (show node) ++ " may only have one file handle") @@ -457,9 +457,9 @@ putcI g node = do x -> return . chr . read $ inL!!r fh <- case fhL of - x | length x == 0 -> return stdout + x | length x == 0 || length x == 1 -> return stdout - x | length x == 1 -> openFile (head fhL) AppendMode + --x | length x == 1 -> openFile (head fhL) AppendMode x -> error ("Instruction " ++ (show node) ++ " may only have one file handle") -- cgit