summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-12-16 12:32:02 +1100
committerJed Barber <jjbarber@y7mail.com>2014-12-16 12:32:02 +1100
commit2909ad4b7b96a93d04c01135683d4dee6356def2 (patch)
treebc5d22d3cca77b4e2762f621d7169f743deddfc3 /src
parentef3babe261b22d44b82b4768339f02486d8cc4ef (diff)
Grasp interpreter main program added, still untested
Diffstat (limited to 'src')
-rw-r--r--src/grasp.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/grasp.hs b/src/grasp.hs
new file mode 100644
index 0000000..4b12abd
--- /dev/null
+++ b/src/grasp.hs
@@ -0,0 +1,30 @@
+
+import System.Environment( getArgs )
+import Control.Exception( ErrorCall(..), Handler(..), catches )
+import Grasp.Parser
+import Grasp.Interpreter
+
+
+
+
+usageString :: String
+usageString = "Usage: grasp <program file>"
+
+
+
+program :: IO ()
+program = do
+ args <- getArgs
+ fileContents <- if (length args /= 1)
+ then error usageString
+ else readFile (head args)
+
+ case (parseGrasp fileContents) of
+ Left x -> putStrLn (show x)
+ Right x -> grasp x >> return ()
+
+
+
+main = catches program
+ [ Handler ((\e -> putStrLn . show $ e) :: ErrorCall -> IO ()) ]
+