-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
07 Resolving #14
07 Resolving #14
Conversation
Let's take a look at the statements returned by the parser:
While our interpreter As it visits each statement, it To do so, it will also need a frame to hold declared variables and their types, and later insert it into |
Like the interpreter, we use multiple dispatch within So far, only output and assign statements require |
The Inspecting the
The frame has been created, and inserted into the |
Reverting the interpreterNow we can undo whatever we had to do to the interpreter to make it insert frames: Bugtracing
Inspecting the expr that caused this:
Of course ... Very fragile! We will come back to fix later. |
Frame passingBug:
We forgot to pass the frame returned by the resolver down to the interpreter. We have to do so since this is the frame that was inserted into the [405e885] Oops, forgot an empty dict is considered |
TestingResult:
We have a working resolver. Much more refactoring ahead, but before we optimise prematurely we also want to consider static typing. |
BugOur main program can't catch |
In later statements we will encounter not just names, but possibly subnames, in code like:
Here,
i
is a name within theframe
of theGetId
function, and does not exist in the globalframe
.Id
is a name within an element ofArray
, and does not exist inGetId
's frame, nor in the global frame.Determining which
frame
to get names from feels like a responsibility beyond the scope ofinterpreter.py
. Who should be responsible for determining theframe
to get a name from?This process is called resolving, and we will build a resolver in this pull request.