Removed adhoc tests

This commit is contained in:
sebastianselander 2023-02-17 12:01:22 +01:00
parent a9f54dbca1
commit f2e8a02255
3 changed files with 64 additions and 79 deletions

View file

@ -1,47 +1,50 @@
{-# LANGUAGE LambdaCase #-}
module Main where
import Grammar.Par (myLexer, pProgram)
import Grammar.Print (printTree)
import System.Environment (getArgs)
import System.Exit (exitFailure, exitSuccess)
import Grammar.Par (myLexer, pProgram)
-- import TypeChecker.TypeChecker (typecheck)
import TypeChecker.Unification (typecheck)
import Renamer.Renamer (rename)
import Grammar.Print (prt)
import Grammar.Print (printTree)
import Renamer.Renamer (rename)
import System.Environment (getArgs)
import System.Exit (exitFailure, exitSuccess)
import TypeChecker.TypeChecker (typecheck)
main :: IO ()
main = getArgs >>= \case
[] -> print "Required file path missing"
(x:_) -> do
file <- readFile x
case pProgram (myLexer file) of
Left err -> do
putStrLn "SYNTAX ERROR"
putStrLn err
exitFailure
Right prg -> do
putStrLn ""
putStrLn " ----- PARSER ----- "
putStrLn ""
putStrLn . printTree $ prg
case rename prg of
Left err -> do
putStrLn "FAILED RENAMING"
putStrLn . show $ err
exitFailure
Right prg ->do
putStrLn ""
putStrLn " ----- RENAMER ----- "
putStrLn ""
putStrLn . printTree $ prg
case typecheck prg of
Left err -> do
putStrLn "TYPECHECK ERROR"
putStrLn . show $ err
exitFailure
Right prg -> do
putStrLn ""
putStrLn " ----- TYPECHECKER ----- "
putStrLn ""
putStrLn . show $ prg
main =
getArgs >>= \case
[] -> print "Required file path missing"
(x : _) -> do
file <- readFile x
case pProgram (myLexer file) of
Left err -> do
putStrLn "SYNTAX ERROR"
putStrLn err
exitFailure
Right prg -> do
putStrLn ""
putStrLn " ----- PARSER ----- "
putStrLn ""
putStrLn . printTree $ prg
case rename prg of
Left err -> do
putStrLn "FAILED RENAMING"
print err
exitFailure
Right prg -> do
putStrLn ""
putStrLn " ----- RENAMER ----- "
putStrLn ""
putStrLn . printTree $ prg
case typecheck prg of
Left err -> do
putStrLn "TYPECHECK ERROR"
print err
exitFailure
Right prg -> do
putStrLn ""
putStrLn " ----- TYPECHECKER ----- "
putStrLn ""
putStrLn . printTree $ prg
exitSuccess