Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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