(Latest Revision: 08/16/2003)
WFF Catcher: A Program That Checks "Well-Formed Formulae"
PRELIMINARIES:
Before working on this problem you need to understand recursion. Read chapter
five of Carranao. You also need to be familiar with the directions and
examples here:
http://www.cs.csustan.edu/~john/Classes/General_Info/progAsgRules/
ASSIGNMENT SYNOPSIS:
Write a program that employs a recursive function to check a series of
strings to see if they are "Well Formed Formulae" (WFF's).
INPUT:
The program reads a series of zero or more strings (strings are separated by
white space) from standard input. There is no other input to the program. This
sample input
illustrates the kind of input I will use to test your program.
OUTPUT:
The program writes all its output standard output. First the program writes a
heading/greeting message. Next, for each input string, the program goes to a
new line of the output, echos (writes) the input string to standard output,
goes to a new line again, and prints a message telling whether the string is a
WFF. Finally the program prints an exit message and stops. There is no other
output.
This
script
shows the output produced in response to the
sample input
file.
DISCUSSION OF PROCESSING:
The following three rules define a well-formed formula (WFF)
- Any one of the three lowercase letters p, q, r, or s is a WFF.
- A letter N, followed by a WFF, is a WFF.
- Any one of the letters C, A, K, or E, followed by two WFF's, is a WFF.
Your solution to this problem must be "recursive" -- it must include a
recursive function that does all the significant work of the
program.
Read the pseudo-code for the "prefix expression recognition algorithm" on
pages 251-252 of Carrano for ideas. My solution code for this problem -- WFF
Catcher -- uses a very similar approach.
TESTING:
Your test script will count for about 15% of your grade on this program. If
you just copy my sample input and make a script with that, you won't get full
credit for testing. You need to create a test suite with better data and code
coverage. We can discuss that in class.
What To Turn In:
This is not going to be a large program. It will probably be a level-three
program with only three or four functions, including the main function.
Therefore, I am not requiring you to turn in a preliminary version.
You will turn in two printer outputs (hardcopies) and you will send me one
e-mail message. Please follow these rules:
- Always send me e-mail as plain text in the main message body. Never
send me attachments.
- Always use the exact subject line I specify for each message.
(I often get hundreds of e-mail messages in a week. The subject line
allows me to find, filter and sort messages.) You will lose a
significant number of points on the assignment if you use the wrong
subject line.
- Be very careful when typing the command to send e-mail. You may use
the instructions in your
Hello World! lab excercise
for guidance. Of course, you will need to make the obvious changes to
those directions -- you have to use the correct subject line and
filename.
- Always send yourself a copy of each e-mail message you send to me, and
check immediately to see if you receive the message intact.
You are responsible for sending e-mail correctly.
Here is the list of things you have to turn in:
- At the start of class on the due date, place the
following items on the "counter" in front of me:
- a hardcopy of your final version of the program source code,
and
- a hardcopy of your test script showing adequate testing of your
program.
Make sure that all of the code and script content shows on the paper.
Make sure all content is plainly readable and properly formatted.
- Send the following item to me by e-mail before midnight on the
due date:
Your
final version of the source code,
with subject line: CS3100,prog1.f.
Note that there are no spaces in the subject lines given above. It is
important that you do not insert any spaces. My e-mail address is:
john@ishi.csustan.edu .
DUE DATES:
For the due dates, see
the class schedule.