Exemplo n.º 1
0
 def __init__(self, script, in_fd=sys.stdin, out_fd=sys.stdout):
     self.out_fd = out_fd
     self.in_fd = in_fd
     self.script = script
     self.cell = Cell()
     self.stack = Stack()
     self.code = CodeFeeder(script, {'[': ']', ']': '['})
     self.opcodes = {
         ">": self.cell.right,
         "<": self.cell.left,
         "+": self.cell.inc,
         "-": self.cell.dec,
         ".": self.print_char,
         ",": self.read_char,
         "[": self.jz,
         "]": self.jnz,
         "\\": self.push,
         "/": self.pop,
         "!": self.pvt
     }
Exemplo n.º 2
0
 def pvt(self):
     old_stack = str(self.stack)
     old_code = str(self.code)
     self.stack = Stack(old_code)
     self.code.build_from(old_stack[::-1])
     self.code.loc_pointer -= 1  #inc after yield, need to fix