unit tests, started on pattern matching
This commit is contained in:
parent
d23d417ff3
commit
05313652f9
9 changed files with 212 additions and 133 deletions
24
src/Main.hs
24
src/Main.hs
|
|
@ -3,7 +3,6 @@
|
|||
module Main where
|
||||
|
||||
-- import Codegen.Codegen (compile)
|
||||
import GHC.IO.Handle.Text (hPutStrLn)
|
||||
import Grammar.ErrM (Err)
|
||||
import Grammar.Par (myLexer, pProgram)
|
||||
import Grammar.Print (printTree)
|
||||
|
|
@ -12,7 +11,6 @@ import Grammar.Print (printTree)
|
|||
import Renamer.Renamer (rename)
|
||||
import System.Environment (getArgs)
|
||||
import System.Exit (exitFailure, exitSuccess)
|
||||
import System.IO (stderr)
|
||||
import TypeChecker.TypeChecker (typecheck)
|
||||
|
||||
main :: IO ()
|
||||
|
|
@ -25,32 +23,28 @@ main' :: String -> IO ()
|
|||
main' s = do
|
||||
file <- readFile s
|
||||
|
||||
printToErr "-- Parse Tree -- "
|
||||
putStrLn "-- Parse Tree -- "
|
||||
parsed <- fromSyntaxErr . pProgram $ myLexer file
|
||||
printToErr $ printTree parsed
|
||||
putStrLn $ printTree parsed
|
||||
|
||||
printToErr "\n-- Renamer --"
|
||||
putStrLn "\n-- Renamer --"
|
||||
let renamed = rename parsed
|
||||
printToErr $ printTree renamed
|
||||
putStrLn $ printTree renamed
|
||||
|
||||
printToErr "\n-- TypeChecker --"
|
||||
putStrLn "\n-- TypeChecker --"
|
||||
typechecked <- fromTypeCheckerErr $ typecheck renamed
|
||||
printToErr $ printTree typechecked
|
||||
putStrLn $ printTree typechecked
|
||||
|
||||
-- printToErr "\n-- Lambda Lifter --"
|
||||
-- putStrLn "\n-- Lambda Lifter --"
|
||||
-- let lifted = lambdaLift typechecked
|
||||
-- printToErr $ printTree lifted
|
||||
-- putStrLn $ printTree lifted
|
||||
|
||||
-- printToErr "\n -- Printing compiler output to stdout --"
|
||||
-- putStrLn "\n -- Printing compiler output to stdout --"
|
||||
-- compiled <- fromCompilerErr $ compile lifted
|
||||
-- putStrLn compiled
|
||||
-- writeFile "llvm.ll" compiled
|
||||
|
||||
exitSuccess
|
||||
|
||||
printToErr :: String -> IO ()
|
||||
printToErr = hPutStrLn stderr
|
||||
|
||||
fromCompilerErr :: Err a -> IO a
|
||||
fromCompilerErr =
|
||||
either
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue