Source

xilocaml / Main.hs

Full commit
module Main where
import ParXilocaml
import ErrM
import Semantics
import Interpreter
import PrettyShow


main :: IO ()
main = do
	interact printResult
	putStrLn ""


printResult :: String -> String
printResult s =
	let result = do
		tree <- pProgram $ myLexer s
		valueType <- checkSemantics tree
		value <- interpret tree
		return (normalize valueType, value)
	in case result of
		Ok (valueType, value) -> (prettyShow value) ++ " : " ++ (prettyShow valueType)
		Bad s -> error s