diff options
Diffstat (limited to 'Main.hs')
-rw-r--r-- | Main.hs | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -1,5 +1,27 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} module Main where +import System.Environment (getArgs) +import System.Exit (die, exitFailure) + +import Parser + main :: IO () -main = putStrLn "hoi" +main = do + (source, fname) <- getArgs >>= \case + [] -> (,"<stdin>") <$> getContents + [fname] -> (,fname) <$> readFile fname + _ -> die "Usage: hs-visinter [filename.hs]" + + prog <- case parse fname source of + This errs -> do + mapM_ (putStrLn . printErrMsg) errs + exitFailure + These errs res -> do + mapM_ (putStrLn . printErrMsg) errs + return res + That res -> return res + + print prog |