aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs
new file mode 100644
index 0000000..c9de0cc
--- /dev/null
+++ b/src/Main.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE TupleSections #-}
+module Main where
+
+import System.Environment (getArgs)
+import System.Exit (die, exitFailure)
+
+import Parser
+
+
+main :: IO ()
+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