A Compiler for Klein
Translation of Programming Languages
The final submission of
the Klein compiler project
OUT: Friday, December 1
DUE: Friday, December 8
A Complete Compiler
This stage consists of a complete implementation of your Klein
compiler, optional code optimization, and a complete set of
- Your primary task is:
Ensure that all the components of your compiler satisfy the
language specification and the project assignment.
- cleaning up every stage of the compiler, fixing any bugs
- making sure that all error messages are as helpful to
the user as possible
In particular, be sure that your compiler traps all errors and
handles them cleanly. Your compiler should never crash, even
in the implementing language. As GCC's
Have You Found a Bug?
If the compiler gets a fatal signal, for any input whatever,
that is a compiler bug. Reliable compilers never crash.
The goal of this project is to write a complete compiler
for the entire Klein programming language. If you are
unable to implement a complete compiler for the entire
language, then your team should make deliberate
choices about which elements of the language to omit.
- Be sure to document any omissions and other design
decisions prominently at the top of your
- Have your compiler print suitable warning and error
messages for language features that are not supported.
- An optional secondary task is:
Implement one or more optimizations that improve the
performance of your compiler.
Improvements can include the reducing size of the generated
TM code, increasing the speed of the generated TM code, or
extending the functional behavior of generated TM code.
Possible optimizations include:
- inlining functions where possible
- compiling recursive tail calls as gotos
- handling other tail calls without extending the stack
- implementing a register selection utility
If you implement one or more optimizations, be sure to
document them prominently at the top of your
If you attempt an optimization but are unable to complete
it, be sure not to break your compiler. A complete, working,
unoptimized compiler is more valuable than an almost optimized
compiler that does not work correctly.
your project directory
conforms to all requirements.
This includes but is not limited to the following:
- Make sure the five scripts that make up the
command-line suite of your compiler are in the
- Make sure that your documentation is complete and that
the files in your doc/ folder have meaningful,
- Your programs/ directory contains all of the
Klein source programs your wrote for the project.
(Source files written only for testing may be placed
in your tests/ directory.)
- Your README file documents the project and the
project directory as specified.
- The final final deliverable
- By 5:00 PM on the due date, submit
your project directory
Make your electronic submission using
the on-line submission system.
- (electronically) a zipped file named
- (hardcopy) no hardcopy required
As always, submit only one copy of each assignment per team,
both electronically and on paper. The team captain or a
designated team member can be responsible for the submission.
Eugene Wallingford .....
December 1, 2017