Check if control in range(255)
This commit is contained in:
parent
2760961550
commit
e3c1672b19
|
@ -23,8 +23,7 @@ class InfiniteArray:
|
|||
|
||||
|
||||
class Machine:
|
||||
def __init__(self, code, read, write, user_data=None, max_cycles=None):
|
||||
self.user_data = user_data
|
||||
def __init__(self, code, read, write, max_cycles=None):
|
||||
self.read = read
|
||||
self.write = write
|
||||
self.mem = InfiniteArray([ord(char) for char in code])
|
||||
|
@ -102,6 +101,7 @@ class Machine:
|
|||
while True:
|
||||
if self.mem[self.exc_ptr] == 0:
|
||||
return
|
||||
if self.mem[self.exc_ptr] <= 255:
|
||||
control = chr(self.mem[self.exc_ptr])
|
||||
if debug:
|
||||
print control
|
||||
|
@ -112,4 +112,5 @@ class Machine:
|
|||
return
|
||||
|
||||
if __name__ == "__main__":
|
||||
Machine(sys.argv[1], sys.stdin.read, sys.stdout.write, None).run()
|
||||
Machine(sys.argv[1], sys.stdin.read, sys.stdout.write,
|
||||
int(sys.argv[2]) if len(sys.argv) >= 2 else None).run()
|
||||
|
|
Loading…
Reference in New Issue
Block a user