Created
May 11, 2018 00:46
-
-
Save evanrinehart/b840d4e56ecab295c74f36210f3ac481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- translate this language | |
-- e = w | x | -e | e + e | let x = e in e | |
-- into this language | |
-- a = [code] | |
-- code = t = t + t (add) | |
-- | t = -t (negate) | |
-- | t = t (copy) | |
-- > example | |
-- Add (Let "x" (Wrd 3) (Add (Var "x") (Wrd 1))) (Add (Neg (Wrd 2)) (Wrd 4)) | |
-- > ppe example | |
-- (let x = 3 in x + 1) + -2 + 4 | |
-- > compile example "@r" | |
-- [@x = 3,%5 = @x,%6 = 1,%0 = %5 + %6,%4 = 2,%2 = -%4,%3 = 4,%1 = %2 + %3,@r = %0 + %1] | |
-- > pp it | |
-- @x = 3 | |
-- %5 = @x | |
-- %6 = 1 | |
-- %0 = %5 + %6 | |
-- %4 = 2 | |
-- %2 = -%4 | |
-- %3 = 4 | |
-- %1 = %2 + %3 | |
-- @r = %0 + %1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment