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

Lab Assignment B

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

The problem: Complete Alex Thornton's ICS 22 lab assignment, "What's Simple Is True," available at http://www.ics.uci.edu/~thornton/ics22/LabManual/Simple/. The assignment involves building an interpreter for a simple programing language like Basic; Alex calls his language Facile. This may seem a little infrastructural for us, but actually, it's not: Sometimes the right way to solve a problem is to make up a special-purpose language that makes it easy to express the various aspects of the problem (and then build an interpreter to process that language). Even the restaurants program is an anemic example of this; we have a "restaurant collection manipulation language" that consists of half a dozen single-letter commands. The second course in programming languages that you'll take next year has this idea as one of its themes. In fact, in a couple of weeks we'll talk a little about the way computer scientists look at languages.

Alex makes a big point in his writeup about how hefty this assignment is, but besides the fact that you're intrepid informaticians, always up for new experiences and challenges, you have two distinct advantages over the ICS 22 students doing this assignment: You're doing it with pair programming, and you've spent a week (last quarter) thinking about machine-level programming, so the concepts in this assignment will be familiar.

Here's a short Facile program to add to the ones in the problem description. You can run it in Alex's Facile interpreter; you can read it to see what it does; you can use it to test your own interpreter (but it does require that you implement one of the optional features—two if you count comments):


* MY FIRST FACILE PROGRAM BY DAVID KAY
LET N 5
LET F 1
GOSUB 6
PRINT F
END
IF N > 1 THEN 8
RETURN
MULT F N
SUB N 1
GOSUB 6
RETURN
.

Alex's assignment asks students to write something called a "programmatic unit tester." ICS 22 covers material in a different order than we do here, so this is something that we have yet to discuss. For this reason, you're not required to implement the "Testing" portion of Alex's assignment. Alex's assignment also requires students to build their own stack class out of an ArrayList. You may do this if you wish, but you may also just use the predefined Stack class in java.util. (Remember that it uses a non-standard name for the "top" operation.)

The approach: First, read the assignment. Not everything will "fall into place" for you on the first reading; that's normal, and that's why we say you'll need to read the assignments more than once. (That's not just a characteristic of our assignments; that's true of any technical specification.) But in your first reading, look at the "Designing your interpreter" section and follow the advice there. Tackle this project, and any large project, one step at a time.

The following usual warnings, advice, policies, and practices apply to this assignment:


Written by David G. Kay, Winter 2005.