diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-08-12 22:53:06 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-08-12 22:53:06 +0100 |
commit | 279f04cb63e45ceb9a9df82540d5362565b8b37b (patch) | |
tree | bf71e8d7829e6ccf29320dacaf7c4742423683c5 /src/Main.hs | |
download | micro-lang-hs-279f04cb63e45ceb9a9df82540d5362565b8b37b.tar.gz micro-lang-hs-279f04cb63e45ceb9a9df82540d5362565b8b37b.zip |
Initial import
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..e428ba5 --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,20 @@ +module Main where + +import Compiler +import Control.Monad.State (evalState) +import qualified Data.Map as Map +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 (compile ast) startState + case res of + Right _ -> print ast + Left errs -> hPutStrLn stderr $ showErrorList errs |