This commit is contained in:
root
2019-08-30 19:30:19 +02:00
commit 6f2b105ca0
595 changed files with 78405 additions and 0 deletions

23
util/sample/haskell.txt Normal file
View File

@@ -0,0 +1,23 @@
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