summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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