X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=Testsyntax.hs;h=45f35b972d017946d22cb22f57d36d3a3b3fb690;hp=fb6986c317591f0b732b6cb8283c8b132cb768e9;hb=93b042040034d199c925248a2dd1c321773ab6d0;hpb=9597d94cbb1b328c27883c8421b1fef3211fb698 diff --git a/Testsyntax.hs b/Testsyntax.hs index fb6986c..45f35b9 100644 --- a/Testsyntax.hs +++ b/Testsyntax.hs @@ -11,10 +11,6 @@ import Skelsyntax import Printsyntax import Abssyntax -import Typecheck -import Control.Monad.State -import Data.Map as Map hiding (showTree) - @@ -29,21 +25,19 @@ type Verbosity = Int 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