summaryrefslogtreecommitdiff
path: root/hs/Main.hs
blob: 5db97ec61880d31c8da002a2872f79f444080d97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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