diff options
Diffstat (limited to 'hs/Main.hs')
-rw-r--r-- | hs/Main.hs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/hs/Main.hs b/hs/Main.hs new file mode 100644 index 0000000..5db97ec --- /dev/null +++ b/hs/Main.hs @@ -0,0 +1,26 @@ +module Main where + +import Control.Monad +import System.Environment +import System.Exit + +-- import AST +import Interpreter +import Parser + + +main :: IO () +main = do + args <- getArgs + when (length args == 0) $ die "Pass source file as parameter" + let fname = head args + src <- readFile fname + let eprog = parseProgram (Just fname) src + prog <- either (die . show) return eprog + -- print prog + -- putStrLn $ astPretty prog + let (merr, output, _) = interpret prog + + maybe (putStrLn "[No errors]") (putStrLn . ("ERROR: " ++)) merr + putStrLn "OUTPUT:" + putStrLn output |