-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompiler.hs
34 lines (27 loc) · 874 Bytes
/
Compiler.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import ASTTypes
import Parser
import SemanticFunctions
-- import Codegen
import SymbolTableTypes
import Emit
import Control.Monad.Trans
import System.IO
import System.Environment
import System.Console.Haskeline
import qualified LLVM.AST as AST
initModule :: AST.Module
initModule = emptyModule "-I'm really happy right now. -Me too <3"
process :: AST.Module -> Word -> String -> IO (Maybe AST.Module)
process modo opt source = do
let parseTree = parse source
ast <- codegen modo parseTree opt -- Optimisation level
return $ Just ast
processFile :: String -> Word -> IO (Maybe AST.Module)
processFile fname opt = readFile fname >>= process initModule opt
main :: IO ()
main = do
args <- getArgs
case args of
[] -> error "No file to compile!"
[fname] -> processFile fname 0 >> return ()
[fname, opt] -> processFile fname 3 >> return ()