Update main.py
This commit is contained in:
parent
749ee8842e
commit
034f9320e1
8
main.py
8
main.py
@ -2,6 +2,7 @@ pointer = 0
|
|||||||
cell = []
|
cell = []
|
||||||
code = ""
|
code = ""
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main function"""
|
"""Main function"""
|
||||||
global code, cell, pointer
|
global code, cell, pointer
|
||||||
@ -21,8 +22,10 @@ def interpreter(znak, i):
|
|||||||
- decrement (decrease by one) the byte at the data pointer.
|
- decrement (decrease by one) the byte at the data pointer.
|
||||||
. output the byte at the data pointer.
|
. output the byte at the data pointer.
|
||||||
, accept one byte of input, storing its value in the byte at the data pointer.
|
, accept one byte of input, storing its value in the byte at the data pointer.
|
||||||
[ if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ]
|
[ if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command,
|
||||||
] if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [."""
|
jump it forward to the command after the matching ]
|
||||||
|
] if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command,
|
||||||
|
jump it back to the command after the matching [."""
|
||||||
global code, cell, pointer
|
global code, cell, pointer
|
||||||
match znak:
|
match znak:
|
||||||
case ">":
|
case ">":
|
||||||
@ -59,5 +62,6 @@ def interpreter(znak, i):
|
|||||||
for j in range(1, loop_end-loop_begin):
|
for j in range(1, loop_end-loop_begin):
|
||||||
interpreter(code[loop_begin + j], loop_begin + j)
|
interpreter(code[loop_begin + j], loop_begin + j)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user