blob: 5ceb967f4e36babd8f718c0675a1dad4fe3ea8f8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module Fun.Compiler where
import Control.Exception
import Fun.Parser
import Fun.Tree
parse :: String -> Either String Program -- TODO: Should be tree
parse file = case program file of
Left a -> Left $ "Invalid code around here:\n" ++ case a of
Nothing -> "[No context]"
Just str -> str
Right (a, b) -> Right a
compile :: String -> IO ()
compile path = do
file <- try $ readFile path
case file of
Left exception -> print (exception :: IOError)
Right file -> case parse file of
Left err -> putStrLn err
Right block -> putStrLn . show $ block
|