Split the compiler into it's own module and added a file for the LLVM standard library.
This commit is contained in:
parent
5524e1ec3e
commit
213e47097e
3 changed files with 13 additions and 6 deletions
34
src/Compiler/Compiler.hs
Normal file
34
src/Compiler/Compiler.hs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
module Compiler.Compiler where
|
||||
|
||||
import Control.Applicative (Applicative)
|
||||
import Control.Monad.Except (Except, MonadError (throwError),
|
||||
liftEither)
|
||||
import Data.Either.Combinators (maybeToRight)
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Map as Map
|
||||
import Grammar.Abs
|
||||
import Grammar.Print (printTree)
|
||||
import Grammar.Par (myLexer,pProgram)
|
||||
import System.Exit (exitFailure)
|
||||
|
||||
compileFile :: String -> IO ()
|
||||
compileFile file = do
|
||||
input <- readFile file
|
||||
case pProgram (myLexer input) of
|
||||
Left err -> do
|
||||
putStrLn "SYNTAX ERROR"
|
||||
putStrLn err
|
||||
exitFailure
|
||||
Right cor -> do
|
||||
putStrLn $ printTree cor
|
||||
compile cor
|
||||
|
||||
-- data Compiler = Compiler
|
||||
-- { data :: [LLVMIr] }
|
||||
--
|
||||
-- data LLVMIr = LLVMIr
|
||||
|
||||
|
||||
|
||||
compile :: Program -> IO ()
|
||||
compile p = print "hej"
|
||||
Loading…
Add table
Add a link
Reference in a new issue