Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Como me quedaron las cosas:
- ...
- eval (Bin b e1 e2) = eval e1 >>= \res -> eval e2 >>= evalBin b res
- ...
- evalBin Lt (VInt n1) (VInt n2) = return $ VBool (n1<n2)
- evalBin Gt (VInt n1) (VInt n2) = return $ VBool (n1>n2)
- ...
- exec (Block sts) = executeAll (map exec sts)
- exec (If ex st1 st2) = (eval ex >>= checkVBool) >>= (\cond -> if cond then exec st1 else exec st2)
- exec (While ex st) = (eval ex >>= checkVBool) >>= (\cond -> if cond then (exec st) >>= (\v -> exec $ While ex st) else return ())
- ...
- executeAll :: [Interpreter ()] -> Interpreter ()
- executeAll [] = return ()
- executeAll (i:is) = i >>= (\v -> executeAll is)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement