Compile program to LLVM #21

Merged
me merged 10 commits from feature-llvm into main 2023-09-29 10:41:05 +00:00
2 changed files with 8 additions and 1 deletions
Showing only changes of commit c296d15f85 - Show all commits

2
.gitignore vendored
View file

@ -21,3 +21,5 @@ cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*
a.out
a.out.ll

View file

@ -5,6 +5,7 @@ module Main (main) where
-- import Compiler.ExeGen
import Compiler.LLVMGen
import Data.Text.Lazy qualified as L
import Data.Text.Lazy.IO qualified as T
import Parser.Expr
import System.Environment
@ -17,5 +18,9 @@ main :: IO ()
main = do
fileName <- fmap head getArgs
contents <- readFile fileName
T.putStrLn "- Parsing file..."
let parsed = getRight (parseExpr contents)
T.putStrLn (llvmGen parsed)
T.putStrLn "- Generating LLVM to './a.out.ll'..."
let llvm = llvmGen parsed
writeFile "a.out.ll" (L.unpack llvm)
T.putStrLn "- Done."