aboutsummaryrefslogtreecommitdiffstats
path: root/app/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/Main.hs b/app/Main.hs
index c71fd2f..45540aa 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -19,6 +19,8 @@ parseArgs config args =
config { configPrintEvaled = True } rest
("-s":rest) -> parseArgs
config { configPrintCallStack = True } rest
+ ("-r":rest) -> parseArgs
+ config { configUseREPL = True } rest
_ -> config
repl :: Config -> Env -> InputT IO ()
@@ -47,7 +49,8 @@ main = do
configVerboseMode = False,
configShowHelp = False,
configPrintEvaled = False,
- configPrintCallStack = False
+ configPrintCallStack = False,
+ configUseREPL = False
}
let config = parseArgs initialConfig args
@@ -58,10 +61,15 @@ main = do
putStrLn $ " " ++ progName ++ " -h # to show this help"
putStrLn $ " " ++ progName ++ " -e # to automatically print results of evaluated expressions to stdout"
putStrLn $ " " ++ progName ++ " -s # to automatically print call stack of evaluated expressions to stdout"
+ putStrLn $ " " ++ progName ++ " -r # to open REPL, even after script file execution"
else do
when (configVerboseMode config) $ do
putStrLn $ "configScriptFileName:\t" ++ (show $ configScriptFileName config)
putStrLn $ "configVerboseMode:\t" ++ (show $ configVerboseMode config)
+ putStrLn $ "configShowHelp:\t" ++ (show $ configShowHelp config)
+ putStrLn $ "configPrintEvaled:\t" ++ (show $ configPrintEvaled config)
+ putStrLn $ "configPrintCallStack:\t" ++ (show $ configPrintCallStack config)
+ putStrLn $ "configUseREPL:\t" ++ (show $ configUseREPL config)
case (configScriptFileName config) of
Just scriptFileName -> do
@@ -70,10 +78,10 @@ main = do
Left (LException mp ex) -> case mp of
Just p -> putStrLn $ p ++ " error: " ++ ex
Nothing -> putStrLn $ "error: " ++ ex
- Right _ -> return ()
+ Right (evaledEnv, _) -> do
+ when (configUseREPL config) $
+ runInputT defaultSettings (repl config evaledEnv)
Nothing -> do
putStrLn $ "Lang REPL"
putStrLn $ "Use CTRL+D to exit"
runInputT defaultSettings (repl config builtinEnv)
-
- return ()