readVariable TInt = get_ 0 1
  where
    get_ :: Int -> Int -> MRSIO Exp
    get_ 0 n = do c <- getChar_IO
                  if isSpace c then
                    get_ 0 n
                  else
                   if c == '-' then
                     get_ 0 (n * (- 1))
                   else
                    if isDigit c then
                      get_ (ord c - 48) n
                    else
                      do putStr_Err $
                           "Read function error. Cannot read type: "
                           ++ show TInt ++ "  " ++ show c ++ " on input";
                         return Null

    get_ i n = do c <- getChar_IO
                  if isDigit c then
                    get_ ((i * 10) + (ord c - 48)) n
                  else
                   if isSpace c then
                     return $ EInt $ toInteger (i * n)
                   else
                    do putStr_Err $
                           "Read function error. Cannot read type: "
                           ++ show TInt ++ "  " ++ show c ++ " on input";
                       return Null


-- interpret stmts ...
readVariable TInt = get_ 0 1
  where
    get_ :: Int -> Int -> MRSIO Exp
    get_ 0 n = do c <- getChar_IO
                  if isSpace c then
                    get_ 0 n
                  else
                   if c == '-' then
                     get_ 0 (n * (- 1))
                   else
                    if isDigit c then
                      get_ (ord c - 48) n
                    else
                      do putStr_Err $
                           "Read function error. Cannot read type: "
                           ++ show TInt ++ "  " ++ show c ++ " on input";
                         return Null

    get_ i n = do c <- getChar_IO
                  if isDigit c then
                    get_ ((i * 10) + (ord c - 48)) n
                  else
                   if isSpace c then
                     return $ EInt $ toInteger (i * n)
                   else
                    do putStr_Err $
                           "Read function error. Cannot read type: "
                           ++ show TInt ++ "  " ++ show c ++ " on input";
                       return Null


-- interpret stmts ...
readVariable TInt = get_ 0 1
  where
    get_ :: Int -> Int -> MRSIO Exp
    get_ 0 n = do c <- getChar_IO
                  if isSpace c then
                    get_ 0 n
                  else
                   if c == '-' then
                     get_ 0 (n * (- 1))
                   else
                    if isDigit c then
                      get_ (ord c - 48) n
                    else
                      do putStr_Err $
                           "Read function error. Cannot read type: "
                           ++ show TInt ++ "  " ++ show c ++ " on input";
                         return Null

    get_ i n = do c <- getChar_IO
                  if isDigit c then
                    get_ ((i * 10) + (ord c - 48)) n
                  else
                   if isSpace c then
                     return $ EInt $ toInteger (i * n)
                   else
                    do putStr_Err $
                           "Read function error. Cannot read type: "
                           ++ show TInt ++ "  " ++ show c ++ " on input";
                       return Null


-- interpret stmts ...