egison 1.0.1 → 1.0.2
raw patch · 2 files changed
+18/−10 lines, 2 files
Files
- Egison.hs +17/−9
- egison.cabal +1/−1
Egison.hs view
@@ -10,7 +10,7 @@ import IO hiding (try) welcomeMsg :: String-welcomeMsg = "Egison, version 1.0.1 : http://hagi.is.s.u-tokyo.ac.jp/~egi/egison/\nWelcome to Egison Interpreter!\n"+welcomeMsg = "Egison, version 1.0.2 : http://hagi.is.s.u-tokyo.ac.jp/~egi/egison/\nWelcome to Egison Interpreter!\n" byebyeMsg :: String byebyeMsg = "\nLeaving Egison.\nByebye. See you again! (^^)/\n"@@ -123,13 +123,15 @@ ret <- liftIO (showValue val) return (ret ++ "\n") executeTopExpression defs (Load filename) = do- str <- liftIO (readFile filename)- topExprs <- readTopExpressionList str- let loop topExprs2 = case topExprs2 of- [] -> return (filename ++ " loaded\n")- topExpr:rest -> do executeTopExpression defs topExpr- loop rest- in loop topExprs+ mStr <- liftIO (readEgisonFile filename)+ case mStr of+ Nothing -> throwError (Default "load error")+ Just str -> do topExprs <- readTopExpressionList str+ let loop topExprs2 = case topExprs2 of+ [] -> return (filename ++ " loaded\n")+ topExpr:rest -> do executeTopExpression defs topExpr+ loop rest+ in loop topExprs executeTopExpression defs Execute = do topFrame <- makeTopFrame defs mainFn <- eval [topFrame] (VariableExp "main" [])@@ -140,9 +142,15 @@ objRef <- liftIO (makeClosure (frame:funEnv) body) cEval objRef return ""- _ -> throwError (Default "main is not function" )+ _ -> throwError (Default "main is not function") +readEgisonFile :: String -> IO (Maybe String)+readEgisonFile filename = catch (do str <- (readFile filename)+ return (Just str))+ (\_ -> return Nothing)++ runRepl :: Definitions -> IO () runRepl defs = do input <- (readPrompt "> ") case input of
egison.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 1.0.1+Version: 1.0.2 -- A short (one-line) description of the package. Synopsis: An Interpreter for the Programming Language Egison