You will first complete semantic analysis for type-checking of Mojo as described in Chapter 5 of the text, by traversing the Abstract Syntax Tree (AST) generated by the parser from Project 2, and checking for various type compatibilities.
The code that you need to complete has been marked with TODO comments.
Before starting this project, familiarize yourself with Chapter 5 of the textbook. In addition to the lectures, this will give you a solid foundation for beginning your work.
svn co svn+ssh://sslab01.cs.purdue.edu/homes/cs352/svn/p3
You will now have a working copy of the project files in the
directory p3
. The p3
directory
contains src
and lib
subdirectories.
The src
subdirectory contains source files for this project.
The lib
subdirectory contains any precompiled class files you
will need to compile this project. (The files are actually configured as an
Eclipse project, so you can also import the p3
directory as
a new project in Eclipse at your convenience.)
All commands below will assume that you have first set your current directory
to the p3/src
subdirectory using the command:
cd p3/srcto enter the
src
subdirectory.
All changes for this project will be done to the semantic analysis
file mojo/Semant.java
in the p3/src
subdirectory.
You can compile the project using the commands:
javac */*.javain the
p3/src
subdirectory.
You can run the type checking phase with the command:
java mojo.Semant filewhere
file
is a Mojo source code file. This will
print out the types declared in the input program, and should also check for
semantic errors in the input program.
In this project, you will be managing symbol tables to associate
semantic values with the declared symbols of the input program. These are
implemented by the mojo.Scope
class.
mojo/Semant.java
file.
cd p3/src/mojo turnin -ccs352 Semant.java
There will be a reconciliation period after initial grading when you will be able to compare outputs of your parser with those of the reference implementation, and you may then offer simple fixes for the TAs to apply to your implementation to improve your grade. These fixes will be accepted only at the discretion of the TAs and the instructor — we will judge what "simple" means!
The reconciliation period is only intended for you to be able to fix simple problems that you may have mistakenly overlooked. Thus, you must make sure to test your implementation thoroughly.