29 lines
745 B
Haskell
29 lines
745 B
Haskell
{-# LANGUAGE ImportQualifiedPost #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Main (main) where
|
|
|
|
-- import Compiler.ExeGen
|
|
import Compiler.LLVMGen
|
|
import Data.ByteString.Char8 qualified as B
|
|
import Data.Text.Lazy.IO qualified as T
|
|
import Parser.Expr
|
|
import System.Environment
|
|
import System.Process
|
|
import Types.Expr
|
|
|
|
getRight :: ParseResult -> Expr
|
|
getRight (Right r) = r
|
|
|
|
main :: IO ()
|
|
main = do
|
|
fileName <- fmap head getArgs
|
|
contents <- readFile fileName
|
|
T.putStrLn "- Parsing file..."
|
|
let parsed = getRight (parseExpr contents)
|
|
T.putStrLn "- Generating LLVM to './a.out.ll'..."
|
|
llvmGen parsed >>= B.writeFile "a.out.ll"
|
|
T.putStrLn "- Compiling to executable './a.out'..."
|
|
callCommand "clang a.out.ll"
|
|
T.putStrLn "- Done."
|