Skip to content

Commit

Permalink
Hack to run semantic analysis before rest of compiler pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-tielen committed Jun 14, 2022
1 parent 5213eb5 commit 08c88fc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ module Main (main) where
import qualified Data.Text.Lazy.IO as T
import Control.Exception
import LLVM.Pretty
import qualified Eclair.AST.Analysis as SA
import Eclair.ArgParser
import Eclair
import GHC.IO.Encoding


-- TODO: remove this hack, should be integrated into main compiler line.
-- this is only needed atm since main compiler pipeline doesn't use the actual semantic analysis results yet.
manualSemanticAnalysis :: FilePath -> IO ()
manualSemanticAnalysis file = do
result <- semanticAnalysis file
liftIO $ forM_ (SA.maybeToSemanticError result) (throwIO . SemanticErr)

main :: IO ()
main = do
setLocaleEncoding utf8
Expand All @@ -19,4 +27,6 @@ main = do
EmitRA -> emitRA
EmitEIR -> emitEIR
EmitLLVM -> emitLLVM
fn file `catch` handleErrors
handle handleErrors $ do
manualSemanticAnalysis file
fn file

0 comments on commit 08c88fc

Please sign in to comment.