Yorkville High School Computer Science Department
Yorkville High School Computer Science Department on Facebook  Yorkville High School Computer Science Department Twitter Feed  Yorkville High School Computer Science Department on Instagram

Yorkville High School Computer Science

ASSIGNMENTS: No Current Assignments

Operating System Design :: Projects :: Compiler Part 2

Rubric
Lesson
Due: Database Error

Problem

The files for this project are in the projects directory under 11 when you downloaded the class software.

You will need two tools: the programming language with which you will implement your compiler and the supplied VM Emulator utility (available in your tools directory) for testing the code generated by your compiler.

Instructions

Chapter 11 includes a proposed, language-independent Compiler API, which can serve as your implementation's blueprint. The proposed implementation is based on morphing the syntax analyzer built in the previous project into a the final compiler. In particular, we propose to gradually replace the software modules that generate passive XML output with software modules that generate VM code. This can be done in two main development stages, as follows.

Stage I: Symbol Table: We suggest to start by building the compiler's symbol table module and using it to extend the syntax analyzer built in Project 10. Presently, whenever an identifier is encountered in the source code, say foo, the syntax analyzer outputs the XML line "<identifier> foo </identifier>". Instead, have your analyzer output the following information as part of its XML output (using some output format of your choice):

You may test your symbol table module and the above capability by running your extended syntax analyzer on the test Jack programs supplied in Project 10. Once the output of your extended syntax analyzer will include the above information, it means that you have developed a complete executable capability to understand the semantics of Jack programs. At this stage you can make the switch to a full-scale compiler, and start generating VM code instead of XML output. This can be done by gradually morphing the code of the extended syntax analyzer into a full-scale compiler.

Stage II: We don't provide specific guidelines on how to develop the code generation features of the compiler (except for the examples given in Chapter 11). Instead, we provide a set of six application programs designed to unit-test these features incrementally. We strongly suggest to test your compiler on these programs in the given order. This way, you will be implicitly guided to build the compiler's code generation capabilities in stages, according to the unfolding demands of each test program.

Testing

Normally, when you compile a program and run into some problems, you conclude that the program has errors and proceed to debug it. In this project the setting is exactly the opposite: all the Jack programs that we supply for testing purposes are error-free. Therefore, if their compilation yields any errors, it's the compiler that you have to fix, not the test programs.

For each test program, go through the following routine:

Yorkville High School Computer Science Department on Facebook Yorkville High School Computer Science Department Twitter Feed Yorkville High School Computer Science Department on Instagram