From 281425310c5db21f87981eeb9601a71d1974d98d Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 10 Apr 2014 05:25:03 +1000 Subject: Rearranging files --- src/fractran.hs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/fractran.hs (limited to 'src/fractran.hs') diff --git a/src/fractran.hs b/src/fractran.hs new file mode 100644 index 0000000..224cb05 --- /dev/null +++ b/src/fractran.hs @@ -0,0 +1,30 @@ + +import System.Environment( getArgs ) +import Control.Exception( ErrorCall(..), Handler(..), catches ) +import Fractran.Parser +import Fractran.Interpreter + + + + +usageString :: String +usageString = "Usage: fractran " + + + +program :: IO () +program = do + args <- getArgs + fileContents <- if (length args /= 1) + then error usageString + else readFile (head args) + + case (parseFractran fileContents) of + Left x -> putStrLn (show x) + Right x -> putStrLn (show (fractran x)) + + + +main = catches program + [ Handler ((\e -> putStrLn . show $ e) :: ErrorCall -> IO ()) ] + -- cgit