churf/src/Main.hs
2023-02-03 16:59:36 +01:00

24 lines
650 B
Haskell

{-# LANGUAGE LambdaCase #-}
module Main where
import Compiler.Compiler (compile)
import Control.Monad.Except (runExcept)
import Grammar.Par (myLexer, pProgram)
import Interpreter (interpret)
import System.Environment (getArgs)
import System.Exit (exitFailure, exitSuccess)
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 -> compile prg