aboutsummaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2023-04-23 16:15:21 +0200
committerTom Smeding <tom@tomsmeding.com>2023-04-23 16:15:21 +0200
commitf43838280ce37c8ce67eda2d36f4021439f0a84c (patch)
tree312d18a829f7fe311ea2a13463600245b2a2d53a /Main.hs
parentb036b1cac1377cdbb9cc57ae6124cd6d6e5775a9 (diff)
Untested minimal viable parser
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs24
1 files changed, 23 insertions, 1 deletions
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
+ [] -> (,"<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