summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCamil Staps2018-02-08 08:59:58 +0100
committerCamil Staps2018-02-08 08:59:58 +0100
commitfcf33950c2632a9b65444586cd3ac415627fab12 (patch)
treec057daff8ed6e6a95cb9f271812141b607b70e7d /src
parentAdd example programs; Main.hs using stdin (diff)
Return codes in Main.hs
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 07733dd..72c577a 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -3,6 +3,7 @@ module Main where
import Prelude hiding(lex)
import System.Environment
+import System.Exit
import Text.Parsec.Error (ParseError)
@@ -16,7 +17,9 @@ main = do
args <- getArgs
contents <- getContents
case lex contents of
- Nothing -> putStrLn "Failed to lex"
+ Nothing -> do
+ putStrLn "Failed to lex"
+ exit 1
Just tks -> if "--parse" `elem` args
then doParse tks
else return ()
@@ -26,4 +29,8 @@ main = do
Left e -> do
putStrLn $ "Failed to parse (" ++ show e ++ "). Tokens were:"
putStrLn $ show tks
+ exit 1
Right pgm -> putStrLn $ prettyPrint pgm
+
+ exit :: Int -> IO ()
+ exit = exitWith . ExitFailure