3 ms·
It's just using the python match statement. https://docs.python.org/3/tutorial/controlflow.html#match-statements https://docs.python.org/3/tutorial/controlflow
by jcul 2y ago
It's just using the python match statement.
https://docs.python.org/3/tutorial/controlflow.html#match-statements https://docs.python.org/3/tutorial/controlflow.html#match-st...
It's like switch in C / C++.
And then it's just looking for the strings "while" or "end".
It's the same as if he had written:
keyword = line.split(maxsplit=1)[0]
if keyword == "while":
...
elif keyword == "end":
...
Then depending on the statement, in the while, if it evaluates to true, it scans forward to find end and continues the program from there.
If the statement is true it evaluates the lines one by one, until hitting end and then scans back to the start of the while to evaluate it again.
The `pc` variable is the line number that is currently being evaluated.