import Printsyntax
import Abssyntax
-import Typecheck
-import Control.Monad.State
-import Data.Map as Map hiding (showTree)
-
putStrV :: Verbosity -> String -> IO ()
putStrV v s = if v > 1 then putStrLn s else return ()
-runFile :: Verbosity -> ParseFun Stms -> FilePath -> IO ()
+runFile :: (Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO ()
runFile v p f = putStrLn f >> readFile f >>= run v p
-run :: Verbosity -> ParseFun Stms -> String -> IO ()
+run :: (Print a, Show a) => Verbosity -> ParseFun a -> String -> IO ()
run v p s = let ts = myLLexer s in case p ts of
- Bad s -> do
- putStrLn "\nParse Failed...\n"
- putStrV v "Tokens:"
- putStrV v $ show ts
- putStrLn s
- Ok (Program s) -> do
- putStrLn "\nParse Successful!"
- showTree v (Program s)
- runStateT (mapM typeCheckStm s) empty
- return ()
+ Bad s -> do putStrLn "\nParse Failed...\n"
+ putStrV v "Tokens:"
+ putStrV v $ show ts
+ putStrLn s
+ Ok tree -> do putStrLn "\nParse Successful!"
+ showTree v tree
+
+
showTree :: (Show a, Print a) => Int -> a -> IO ()
showTree v tree