Advertisement
fabiommendes

Untitled

Dec 2nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1.  
  2. ('for', start, cond, iter, block)
  3.  
  4. class Node:
  5.     def print(self, indent=0):
  6.         raise NotImplementedError
  7.  
  8.     def eval(self, env):
  9.         raise NotImplementedError
  10.  
  11.  
  12. from collections import namedtuple
  13.  
  14. @namedtuple
  15. class For(Node):
  16.     start: Node
  17.     cond: Node
  18.     iter: Node
  19.     body: Node
  20.  
  21.     def print(self, indent=0):
  22.         ...
  23.  
  24.     def check(self, env):
  25.         pass
  26.  
  27.     def eval(self, env):
  28.         self.start.eval(env)
  29.         while self.cond.eval(env):
  30.             self.body.eval(env)
  31.             self.iter.eval(env)
  32.  
  33. n = For(start, cond, iter, block)
  34. n.print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement