Create compiler facade for Tokenizer, Parser and Emitter

This commit is contained in:
2021-11-08 16:42:28 +01:00
parent e353caca8d
commit f9496adf8c
3 changed files with 27 additions and 1 deletions

View File

@@ -1,4 +1,19 @@
module Main where
import System.Environment
import qualified Data.ByteString as B
import qualified VirtualMachine as VM
import Assembler.Compiler (compile)
run :: String -> IO ()
run input = case compile input of
(Right bytes) -> print $ VM.run VM.empty (B.pack bytes)
(Left err) -> putStrLn err
main :: IO ()
main = putStrLn "Hello, Haskell!"
main = do
(filename:_) <- getArgs
input <- readFile filename
run input