The goal of this project is to explore the effect of pointers and dynamic memory. In this project you will complete an interpreter for PoiJay. (Looking ahead, the upcoming topics include structs (records) and arrays. Project 5 will be translating RecRayJay (Jay with records and Arrays) to PoiJay. This current project is a very easy one. The next one will be a very hard one.)
Copy and untar the starter code for this project.
cp ~tvandrun/Public/cs365/proj4.tar . tar xvf proj4.tar
The tar file contains both the poijay package and
(part of) the funjay package.
This is because poijay is added on to funjay
(so, it has procedures, globals, etc) and in fact the
typeCheckerVisitor
and interpreterVisitor
for PoiJay simply
extend the respective visitor classes from FunJay.
All that needs to be added to the interpreter visitor
is visit methods for the handful of new constructs.
visit_LeftHandSide
, note that
a LeftHandSide
node has a root
(the name of the variable) which you are unlikely to need,
a varInfo
that contains the offset of the variable
and whether or not it is global.
Note that Mu
may throw an illegal access exception.
You must handle this by terminating the program with an appropriate
message (that it was an illegal access in a left hand side).
There is a similar situation for visit_Dereference
.
visit_LeftHandSide
and
visit_Assignment
are somehow going to need
to communicate with each other.
Malloc
, note that Mu
has an allocate
method.
It potentially throws a MemoryExhaustedException
.
You should handle it by exiting with an appropriate
error message.
Note that there also could be a memory exhausted exception
if the call stack overflows; the error message should
distinguish these.
Copy your InterpeterVisitor.py
to
/cslab.all/linux/class/cs365/(your id)/proj4
I will grade your project by running it against a collection of test files.
DUE: Wednesday, Feb 24, 5:00 pm.