diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-06 18:25:47 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-06 18:25:47 +0200 |
| commit | 4de1c9b9159305a664a56589b9b6aa1bce0129aa (patch) | |
| tree | 949ee8f99d7fc3bae176e094b4a66f310a21ddfd /src | |
| parent | 765d25857b0472e3f9df89ac822ad36ea0502466 (diff) | |
Refactor -e option into -E and -e
Diffstat (limited to 'src')
| -rw-r--r-- | src/Interpreter.hs | 14 | ||||
| -rw-r--r-- | src/Utils.hs | 8 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/Interpreter.hs b/src/Interpreter.hs index f9e00b9..3e74c37 100644 --- a/src/Interpreter.hs +++ b/src/Interpreter.hs @@ -205,7 +205,8 @@ evaluateImport asts = do args = tail asts d <- getDepth - when (d > 1) $ throwL (astPos importAst) $ "import can only be called on the top level, current depth: " ++ show d + when (d > 1) $ throwL (astPos importAst) $ + "import can only be called on the top level, current depth: " ++ show d config <- getConfig let initialState = LState { @@ -423,8 +424,15 @@ runInlineScript' lineNo fileName src = do liftIO $ putStrLn output evaluated <- foldEvaluate parsed - when (configPrintEvaled config) $ do - liftIO $ mapM_ putStrLn (map show evaluated) + + case configPrintEvaled config of + PrintEvaledAll -> liftIO $ mapM_ putStrLn (map show evaluated) + PrintEvaledNonUnit -> do + let evaledNonUnits = evaluated $> + filter (\case AST { astNode = ASTUnit } -> False + _ -> True) + liftIO $ mapM_ putStrLn (map show evaledNonUnits) + PrintEvaledOff -> return () return evaluated where diff --git a/src/Utils.hs b/src/Utils.hs index 2f9e3c0..c2a5088 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -15,11 +15,17 @@ type PositionString = String type ErrorString = String data LException = LException (Maybe PositionString) ErrorString +data PrintEvaled + = PrintEvaledOff + | PrintEvaledAll + | PrintEvaledNonUnit + deriving Show + data Config = Config { configScriptFileName :: Maybe String, configVerboseMode :: Bool, configShowHelp :: Bool, - configPrintEvaled :: Bool, + configPrintEvaled :: PrintEvaled, configPrintCallStack :: Bool, configUseREPL :: Bool } |
