module Main where import Compiler import Control.Monad.State (evalState) import qualified Data.Map as Map import Error (showErrorList) import Lexer (scan) import Parser (parse, parseFromFile) import System.Exit (exitFailure) import System.IO (hPutStrLn, stderr, stdout) main :: IO () main = do res <- parseFromFile (scan parse) "input" case res of Left err -> hPutStrLn stderr ("error: " ++ show err) >> exitFailure Right ast -> do res <- return $ evalState (compileAll ast) startState case res of Right _ -> print ast Left errs -> hPutStrLn stderr $ showErrorList errs