(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)
  1. Any one of the three lowercase letters p, q, r, or s is a WFF.
  2. A letter N, followed by a WFF, is a WFF.
  3. 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: Here is the list of things you have to turn in:
  1. At the start of class on the due date, place the following items on the "counter" in front of me:

    Make sure that all of the code and script content shows on the paper. Make sure all content is plainly readable and properly formatted.

  2. 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.