UCLA CS 132 Compiler Construction Fall 2011

Homework submission tips

Homeworks will be graded on SEASnet's GNU/Linux based servers. If you want to debug the software on your own machine that is fine, but make sure it runs nicely on SEASnet. On SEASnet, prepend /usr/local/cs/bin to your PATH to get the same software versions that the grader is using. When testing on SEASnet, please take care to not run commands like su and sudo that would make it appear to the system administrators that you might be trying to break into the system.

Homeworks 2 through 5 use a variety of tools that you can either download to your personal computer, or run on SEASnet. These include JavaCC and JTB; and SPIM. A Vapor and Vapor-M interpreter is also available. These implementations are all available on SEASnet using the commands javacc, jjdoc and jjtree for JavaCC, jtb for JTB, vapor for Vapor and vapor -mips for Vapor-M, and spim or xspim (the X Window System version) for SPIM. If you are run these programs on your personal computer, please make sure that you are running the latest stable version of Java.

To submit Homework 2, put all your submitted files into a subdirectory named hw2. Another file should be named hw2/Typecheck.java and should contain your Typecheck class source code. You may submit other files; however, do not submit the outputs of jtb, javacc, or javac as we will generate those for you when testing.

Once you've created the hw2 directory and its files, then create a single gzipped tar file hw2.tgz using the following shell command on SEASnet:

gtar czf hw2.tgz hw2

This is the file that you should submit via CCLE. However, do not submit hw2.tgz file right away. Instead, run the following shell commands on SEASnet first; if they do not work (e.g., one of the test outputs a FAILED message), fix hw2.tgz and rerun all the tests from scratch before submitting it.

# Remove the directory 'testdir' if it exists;
# then make a new 'testdir' directory and change into it.
rm -fr testdir
mkdir testdir
cd testdir

# Get the source code into the test directory.
gtar xf ../hw2.tgz

# Change into the source directory, and check the validity of the
# files in it.
cd hw2

# Check that you don't have weird characters in your files.
sh -c 'LC_ALL=C grep -rn '\''[^[:space:][:print:]]'\'' .' && echo 'Weird-character test FAILED.'

# Make sure jtb and javacc are in your PATH.
# They live in /usr/local/cs/bin, so
# if you use csh or tcsh, execute this:
set path=(/usr/local/cs/bin $path)
# and if you use Bash or ksh, uncomment and execute this:
#export PATH=/usr/local/cs/bin:$PATH

# Build the parser source code.
wget http://compilers.cs.ucla.edu/cs132/project/minijava.jj
jtb minijava.jj
javacc jtb.out.jj

# Compile your type checker.
javac Typecheck.java

# Get the test cases.
wget http://compilers.cs.ucla.edu/cs132/project/mj/Factorial.java
wget http://compilers.cs.ucla.edu/cs132/project/mj/Factorial-error.java

# Run the test cases and complain if the output isn't exactly right.
test "`java Typecheck <Factorial.java || echo failed`" = "Program type checked successfully" || echo 'Factorial test FAILED.'
test "`java Typecheck <Factorial-error.java || echo failed`" = "Type error" || echo 'Factorial-error test FAILED.'

Submissions for Homeworks 3 through 5 should follow a similar rule.