Informatics 42 • Winter 2008 • David G. Kay • UC Irvine

Lab Assignment C

This assignment is due at the end of lab on Wednesday, February 20.

The problem: Complete Alex Thornton's version of the ICS 22 lab assignment, "Signal to Noise," available at http://www.ics.uci.edu/~thornton/ics22/LabManual/SignalToNoise/. You'll write a program that reads a grammar and generates a specified number of sentences using this grammar. Before you work on your own program, you can get a broader idea of what's possible by trying out the applet at http://www-cs-faculty.stanford.edu/~zelenski/rsg. The "Extension Request" grammar (the default) is pretty funny; also try out "CS assignment," "Programming bug," and "Math expression," along with any others that strike your fancy. Then follow the "Directory of the collected grammar files" link at the bottom of the page. For an idea of your program's possible input, pick some of those grammars to look at; "Math expression" is the easiest to follow. (There may be slight differences in grammar format between what's shown here and Alex's assignment; follow the assignment in that case.)

Entertainment isn't the only application of this program. Sometimes we need to test our software with a lot of data, more than we can conveniently generate by hand. With a program like this, we only need to create a grammar describing our test data an we can produce as much as we want.

Take note of these three additions/enhancements/clarifications to Alex's writeup:

When you face a program like this one (or the one you wrote in the last lab assignment), it's important to take it in stages. It's a bad idea to try to work on everything at once, nor is it a good practice to wait until you think you've got everything working before you start running and testing your program. One of the skills that you will begin to develop as you work on ever-larger programs is the ability to carve up a large program into smaller pieces that can be tested individually.

As you work on this lab assignment, consider working on it in the following stages.


Submit your own grammar files along with your code. Aside from that, the usual warnings, advice, policies, and practices apply to this assignment:


Written by David G. Kay, Winter 2005; modified by Alex Thornton, Winter 2007, and by David G. Kay, Winter 2008.