From 266286d108b8304efc67d64f47c1ee9d8d4b17c9 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 17 Aug 2022 18:09:11 +0200 Subject: Added input instruction --- src/Eval.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Eval.hs') diff --git a/src/Eval.hs b/src/Eval.hs index 4051643..c80212d 100644 --- a/src/Eval.hs +++ b/src/Eval.hs @@ -122,6 +122,13 @@ evalInstruction (ContextualInstruction instr inp) s@(EnvState env) rec conf = ca then (putStrLn $ name <> " = " <> show e) >> return (EnvState env') else rec (EnvState env') conf + Input path -> do + lib <- getDataFileName path -- TODO: Use actual lib directory + exists <- doesFileExist lib + actual <- pure $ if exists then lib else path + if actual `elem` evalPaths conf then print (ContextualError (ImportError path) (Context inp $ nicePath conf)) >> pure s else do + EnvState env' <- loadFile actual (conf { nicePath = path }) -- TODO: Fix wrong `within` in import error + rec (EnvState $ env' <> env) (conf { isRepl = False, evalPaths = evalPaths conf }) -- import => isRepl = False -- TODO: Don't import subimports into main env Import path namespace -> do lib <- getDataFileName path -- TODO: Use actual lib directory -- cgit v1.2.3