The project
Michael and Laurie's original JOOS compiler is very nice indeed and
has received the excellent grade of A-. However, there is room for
improvement, which could elevate their grade to an amazing A+. There
are four such improvements. This year we will only do the peephole
optimizer part of the A+ project.
C-style comments
The A- implementation only allows one-line comments such as:
// this is a comment
It would also be nice to allow multi-line comments such as:
/* this is a
somewhat
longer comment */
This improvement can be implemented by only making changes to the
file joos.l .
Increments and for-loops
It would be nice to include standard increments and for-loops such as:
for (i=0; i<10; i++) k=k*i;
These constructs may be introduced as mere syntactic sugar, since
they can readily be expressed in the JOOS language itself.
This improvement can be implemented by only making changes to the
files
joos.l and
joos.y .
Correct stack limits
The weakest point of the A- implementation is the stupid computation of
stack limits, which are always assumed to equal 25. It would be much
nicer to compute the exact limit. This improvement can be implemented by only
making changes to the
file emit.c .
More peephole patterns
The peephole optimizer provides a nice framework, but the A-
implementation only includes four peephole patterns. Surely, many more
can be discovered. This improvement can be implemented by only making
changes to the file optimize.c .
|