31 lines
805 B
Haskell
31 lines
805 B
Haskell
module FileEval where
|
|
|
|
import Eval
|
|
import Parser
|
|
import Research
|
|
|
|
import System.IO
|
|
|
|
import qualified Data.Map as Map
|
|
|
|
evaluateFileResult :: FilePath -> IO T
|
|
evaluateFileResult filePath = do
|
|
contents <- readFile filePath
|
|
let asts = parseTricu contents
|
|
let finalEnv = evalTricu Map.empty asts
|
|
case Map.lookup "__result" finalEnv of
|
|
Just finalResult -> return finalResult
|
|
Nothing -> errorWithoutStackTrace "No expressions to evaluate found"
|
|
|
|
evaluateFile :: FilePath -> IO Env
|
|
evaluateFile filePath = do
|
|
contents <- readFile filePath
|
|
let asts = parseTricu contents
|
|
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
|