Skip to content

Instantly share code, notes, and snippets.

@jkoppel
Last active March 3, 2019 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkoppel/f457b2635ccd203099bd8d993fc9d6a1 to your computer and use it in GitHub Desktop.
Save jkoppel/f457b2635ccd203099bd8d993fc9d6a1 to your computer and use it in GitHub Desktop.
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