Homework for UCLA Computer Science 132, Spring 2011

Submit your assignments electronically on CourseWeb.

You are expected to do your homeworks by yourself. You can share ideas and discuss general principles with others in the class, but all the code that you submit must be your own work; do not share your homework code with others. See Grading for more details. Consult a TA or the instructor if you have any questions about this policy.

Any programs that you write must behave robustly. Among other things, this means they must avoid arbitrary limits on the length or number of any data structure, including symbols, strings, and line length. It is OK to impose a non-arbitrary limit, e.g., because your computer runs out of memory or because of the limited range of the Java int type, but it is not OK to impose an arbitrary limit, e.g., a limit of at most 255 characters in a symbol.

Please stick to coding styles used in the course material rather than inventing your own style, as this saves work for the grader.

Assignments are due by 23:59:59 on the specified date (i.e., one second before midnight at the end of the day).

Assignments and their schedule are tentative. Any changes will be noted in the news.

weight due assignment
5% 2011-04-08 1. LL(1) parsing
10% 2011-04-22 2. Type checking of MiniJava
14% 2011-05-13 3. MiniJava → Vapor
13% 2011-05-30 4. Vapor → Vapor-M
13% 2011-05-30 5. Vapor-M → MIPS
5% 2011-06-01 6. LALR(1) parsing with Bison

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 to Courseweb. 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.

See the grading policy for how assignments are treated when late, and for what the maximum score is.


© 1999, 2003–2007, 2011 Paul Eggert. See copying rules.
$Id: homework.html,v 1.13 2011/04/25 23:43:17 eggert Exp eggert $