Provide "library" via tricu file directly
Allows easier loading of other files and drops the list of Haskell strings containing the basic tools included
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
module FileEval where
|
||||
|
||||
import Eval
|
||||
import Library
|
||||
import Parser
|
||||
import Research
|
||||
|
||||
@ -9,17 +8,23 @@ import System.IO
|
||||
|
||||
import qualified Data.Map as Map
|
||||
|
||||
evaluateFile :: FilePath -> IO T
|
||||
evaluateFile filePath = do
|
||||
evaluateFileResult :: FilePath -> IO T
|
||||
evaluateFileResult filePath = do
|
||||
contents <- readFile filePath
|
||||
let asts = parseTricu contents
|
||||
let finalEnv = evalTricu library asts
|
||||
let finalEnv = evalTricu Map.empty asts
|
||||
case Map.lookup "__result" finalEnv of
|
||||
Just finalResult -> return finalResult
|
||||
Nothing -> error "No result found in final environment"
|
||||
|
||||
evaluateFileEnv :: FilePath -> IO Env
|
||||
evaluateFileEnv filePath = do
|
||||
evaluateFile :: FilePath -> IO Env
|
||||
evaluateFile filePath = do
|
||||
contents <- readFile filePath
|
||||
let asts = parseTricu contents
|
||||
pure $ evalTricu library asts
|
||||
pure $ evalTricu Map.empty asts
|
||||
|
||||
evaluateFileWithContext :: Env -> FilePath -> IO Env
|
||||
evaluateFileWithContext env filePath = do
|
||||
contents <- readFile filePath
|
||||
let asts = parseTricu contents
|
||||
pure $ evalTricu env asts
|
||||
|
Reference in New Issue
Block a user