From f43838280ce37c8ce67eda2d36f4021439f0a84c Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 23 Apr 2023 16:15:21 +0200 Subject: Untested minimal viable parser --- Main.hs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index 72f36b2..53b2472 100644 --- a/Main.hs +++ b/Main.hs @@ -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 + [] -> (,"") <$> 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 -- cgit v1.2.3-70-g09d2