packages feed

egison 2.4.4 → 2.4.5

raw patch · 3 files changed

+89/−21 lines, 3 filesdep ~haskelinePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: haskeline

API changes (from Hackage documentation)

Files

egison.cabal view
@@ -1,5 +1,5 @@ Name:                egison-Version:             2.4.4+Version:             2.4.5 Synopsis:            An Interpreter and Compiler for the Programming Language Egison Description:         An interpreter and compiler for the programming language Egison.                      A feature of Egison is the strong pattern match facility.@@ -7,7 +7,7 @@                      especially for collection data, such as lists, multisets, sets, and so on.                      This package include sample Egison program codes "*-test.egi" in "sample/" directory.                      This package also include Emacs Lisp file "egison-mode.el" in "elisp/" directory.-Homepage:            http://hagi.is.s.u-tokyo.ac.jp/~egi/egison/+Homepage:            http://egison.pira.jp License:             MIT License-file:        LICENSE Author:              Satoshi Egi@@ -28,7 +28,7 @@                      etc/template-for-test.hs  Library-  Build-Depends:   base >= 4.0 && < 5, array, containers, haskeline >= 0.7.0.3, transformers, mtl, parsec >= 3.0, directory, ghc, ghc-paths, strict-io+  Build-Depends:   base >= 4.0 && < 5, array, containers, haskeline, transformers, mtl, parsec >= 3.0, directory, ghc, ghc-paths, strict-io   Hs-Source-Dirs:  hs-src   Exposed-Modules: Language.Egison.Core                    Language.Egison.Types@@ -42,7 +42,7 @@  Executable egison   Main-is:             egisoni.hs-  Build-depends:       egison, base >= 4.0 && < 5, array, containers, haskeline >= 0.7.0.3, transformers, mtl, parsec >= 3.0, directory, ghc, ghc-paths, regex-posix, strict-io+  Build-depends:       egison, base >= 4.0 && < 5, array, containers, haskeline, transformers, mtl, parsec >= 3.0, directory, ghc, ghc-paths, regex-posix, strict-io   Other-modules:       Paths_egison   Hs-Source-Dirs:      hs-src/Interpreter   
hs-src/Interpreter/egisoni.hs view
@@ -3,18 +3,86 @@ import Language.Egison.Parser import Language.Egison.Types     -- Egison data types import Language.Egison.Variables -- Egison variable operations+import System.Console.GetOpt import Control.Monad.Error import System.IO import System.Environment import System.Console.Haskeline+import System.Exit (ExitCode (..), exitWith, exitFailure) import Text.Regex.Posix  main :: IO ()-main = do args <- getArgs-          if null args then do showBanner-                               runRepl-                       else runOne $ args+main = do+  args <- getArgs+  let (actions, nonOpts, _) = getOpt Permute options args+  let opts = foldl (flip id) defaultOptions actions+  case opts of+    Options {optShowHelp = True} -> printHelp+    Options {optShowVersion = True} -> printVersionNumber+    Options {optPrompt = prompt, optShowBanner = bannerFlag} ->+      if null nonOpts+        then do if bannerFlag+                   then showBanner+                   else return ()+                runRepl prompt+                if bannerFlag+                  then showByebyeMessage+                  else return ()+        else do runOne $ nonOpts +data Options = Options {+    optShowVersion :: Bool,+    optShowHelp :: Bool,+    optShowBanner :: Bool,+    optPrompt :: String+    }++showUsage :: IO ()+showUsage = do+  putStrLn "egisonc: no input files"+  +defaultOptions :: Options+defaultOptions = Options {+    optShowVersion = False,+    optShowHelp = False,+    optShowBanner = True,+    optPrompt = "> "+    }++options :: [OptDescr (Options -> Options)]+options = [+  Option ['v', 'V'] ["version"]+    (NoArg (\opts -> opts {optShowVersion = True}))+    "show version number",+  Option ['h', '?'] ["help"]+    (NoArg (\opts -> opts {optShowHelp = True}))+    "show usage information",+  Option [] ["no-banner"]+    (NoArg (\opts -> opts {optShowBanner = False}))+    "show usage information",+  Option ['p'] ["prompt"]+    (ReqArg (\prompt opts -> opts {optPrompt = prompt})+            "String")+    "output file to write"+  ]++printVersionNumber :: IO ()+printVersionNumber = do+  putStrLn egisonVersion+  exitWith ExitSuccess++printHelp :: IO ()+printHelp = do+  putStrLn "Usage: egisonc [options] file"+  putStrLn ""+  putStrLn "Options:"+  putStrLn "  --help                Display this information"+  putStrLn "  --version             Display egison version information"+  putStrLn "  --no-banner           Don't show banner"+  putStrLn "  --prompt string       Set prompt of the interpreter"+  putStrLn ""+  exitWith ExitSuccess+ -- REPL Section flushStr :: String -> IO () flushStr str = putStr str >> hFlush stdout@@ -38,33 +106,33 @@           _  -> return ())  -- |Start the REPL (interactive interpreter)-runRepl :: IO ()-runRepl = do+runRepl :: String -> IO ()+runRepl prompt = do     env <- primitiveBindings     _ <- loadLibraries env-    runInputT defaultSettings (loop env "> " "")+    runInputT defaultSettings (loop env prompt "")     where         loop :: Env -> String -> String -> InputT IO ()-        loop env prompt input0 = do-            minput <- getInputLine prompt+        loop env prompt2 input0 = do+            minput <- getInputLine prompt2             case minput of-                Nothing -> liftIO showByebyeMessage+                Nothing -> return ()                 Just "" -> if input0 == ""-                             then loop env "> " ""-                             else loop env "  " (input0 ++ "\n")+                             then loop env prompt2 ""+                             else loop env (take (length prompt) (repeat ' ')) (input0 ++ "\n")                 Just input -> do                   let newInput = input0 ++ input                   let eTopExpr = readTopExpr newInput                   case eTopExpr of                     Left e -> do                       if show e =~ "unexpected end of input" -- Is this really OK?-                        then loop env "  " $ newInput ++ "\n"+                        then loop env (take (length prompt) (repeat ' ')) $ newInput ++ "\n"                         else do liftIO $ putStrLn $ show e-                                loop env "> " ""+                                loop env prompt ""                     Right _ -> do                       result <- liftIO (evalString env newInput)                       if (length result) > 0                         then do outputStrLn result-                                loop env "> " ""-                        else loop env "> " ""+                                loop env prompt ""+                        else loop env prompt "" 
hs-src/Language/Egison/Core.hs view
@@ -23,7 +23,7 @@ showBanner :: IO () showBanner = do   putStrLn $ "Egison Version " ++ egisonVersion ++ " (c) 2011-2012 Satoshi Egi"-  putStrLn $ "http://hagi.is.s.u-tokyo.ac.jp/~egi/egison/"+  putStrLn $ "http://egison.pira.jp"   putStrLn $ "Welcome to Egison Interpreter!"  -- |A utility function to display the egison console byebye message