Last active
March 3, 2019 19:45
-
-
Save jkoppel/f457b2635ccd203099bd8d993fc9d6a1 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
class Var: | |
def __init__(self, name): | |
self.name = name | |
def execute(self, bindings): | |
return bindings[self.name] | |
class ConstInt: | |
def __init__(self, val): | |
self.val = val | |
def execute(self, bindings): | |
return self.val | |
class Add: | |
def __init__(self, left, right): | |
self.left = left | |
self.right = right | |
def execute(self, bindings): | |
return self.left.execute(bindings) + self.right.execute(bindings) | |
class Mul: | |
def __init__(self, left, right): | |
self.left = left | |
self.right = right | |
def execute(self, bindings): | |
return self.left.execute(bindings) * self.right.execute(bindings) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment