]> ruin.nu Git - proglang.git/blobdiff - Interpret.hs
merged changes to function branch
[proglang.git] / Interpret.hs
index 0e3928587d30ecb247b6833adc4a28ffaff1840f..5afcefb10b28cd6ac4a390e71958499b5cfdc956 100644 (file)
@@ -1,4 +1,4 @@
-module Interpret (eval, execute,addFunction, emptyState, Value(..), State(..)) where
+module Interpret (interpret, eval, execute,addFunction, emptyState, Value(..), State(..)) where
 
 import Abssyntax
 import Control.Monad.State hiding (State)
@@ -21,6 +21,12 @@ type Function = ([Decl],[Stm])
 
 data State = State {variables::Variables,functions::(Map Ident Function),ret::(MVar Value)}
 
+interpret :: [Func] -> [Stm] -> IO ()
+interpret fun st = do
+       mv <- newEmptyMVar
+       runStateT (do mapM Interpret.addFunction fun; mapM execute st) emptyState{ret=mv}
+       return ()
+
 --eval :: (MonadState Variables m) => Exp -> m Value
 eval :: Exp -> StateT State IO Value
 eval (EBool b) = return (VBool b)