| # | Due Date | Assignment |
|---|---|---|
| P0 | Fri, 2/2 11:59 PM |
Part 0 |
| P1 | Fri, 2/9 11:59 PM |
Part 1 |
| P2C | Fri, 3/2 11:59 PM |
See CMS |
| P3C | Fri, 3/28 11:59PM |
Part 3 Doc
Compiler Specifications Part 3 Source Files & AMS - See CMS |
| P4C (design doc) | TBA 11:59PM |
Part 4 Doc (TBA) |
| P5C (compiler) | TBA 11:59PM |
Part 5 Doc (TBA)
Bali |
Bali (sometimes referred to as Bali++) is the language for which you will be writing a compiler. This semester's Bali is mostly based on C with simplifications intended to help you write your compiler. Bali is designed to be LLR(1) compliant, which means that it can be parsed using a recursive descent compiler.
The major part of this course is to develop a compiler that compiles Bali into SaM. As you know, Bali is a high-level language, while SaM is an assembly-like language. Of course, Bali is easier to program in, but like all high-level languages, it must be compiled to assembly language in order to run on any platform. This page contains information on how to develop your compiler.
Your compiler will depend on several different packages. The first is SaM. You have already been
using the simulator GUI, but your code will be using the I/O classes developed for SaM, known as
SamTokenizer. We provide documentation for SamTokenizer in the document linked above. You
should also look at the Javadoc for SamTokenizer and the SaM Design Document.
You will also need to use the Bali exception classes and the CS212Compiler interface
that your compiler must implement. The AMS package you download for each part of the project contains a
compiled copy of the latest classes, but we also provide the source code here so that you have an idea
of how they work:
You will need to import each class to be able to use it. They are all contained in the
edu.cornell.cs.bali.compiler package. Also note that IllegalBaliException is
an abstract class and cannot be instantiated.
Be sure to read the Java Help page for information on how to develop your compiler using IDEs.
The templates document contains the Samcode for most Bali constructs. Please use the document to save time and have your compiler generate the correct Samcode.
To build your compiler using the command line, you must include the AMS package on the classpath. To do so, use the following command:
javac -classpath AMS_JAR_Package
BaliCompiler.javaWe also provide an example compiler:
You do not need to use this as the base for your code, but it may provide a good starting point. Use the classes mentioned above for your compiler, and refer to the documentation provided. Also, make sure to follow all the specifications we provide for your compiler. Finally, make sure you read the Java style we require you to have.
There are two methods for running and testing your compiler. First, is the AMS tester that is included in the submission package. This is the same code we use to test your submission and allows you to rapidly test your compiler using multiple test cases. We strongly encourage you to take advantage of this software.
Second, you may use BC.java which is a command line
application that uses your compiler to compile an input file. You may use the same command that compiles