crayon-syntax-highlighter/util/sample/haskell.txt
2019-08-30 19:30:19 +02:00

24 lines
820 B
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module Interpret(interpret) where
import Prog
import System.IO.Unsafe
import Control.Monad
import Char
-- In a call to this function such as "interpret prog vars entry debug":
-- prog is the ABCD program to be interpreted;
-- vars represents the initial values of the four variables;
-- entry is the name of the entry point function, "main" by default; and
-- debug specifies whether the user wants debugging output.
interpret :: Prog -> Vars -> String -> MaybeDebug -> IO ()
interpret prog vars entry debug = do
    let context = Context prog vars entry debug 0
    let newContext = runFunc entry context
    let output =
        case newContext of
            IError s -> "abcdi: " ++ s
            IOK c -> (strVal (getVar A (cVars c))) ++ "\n"
    putStrLn output