(Latest Revision: 02/11/2004)

EXPR Checker: A Program That Checks To See If Expressions are Well Formed


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


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 to 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 well formed expression. 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 rule defines a well formed expression:

<expression> = Yep | Nope <expression> | <expression> Yep

Your solution to this problem must be "recursive" -- it must include a recursive function that does all the significant work of the program.

This problem is a little like two of the problems in chapter 5 of Carrano. Look over pages 246-247 to see what I mean. You can get some ideas for a solution there. In your solution code, you may want to use the substr method of the string object. See page A33 of Carrano for details.


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 will get practically no 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:

I am not requiring you to turn in a preliminary version. One can solve this problem with a very small program. My solution has just two functions, including main. You should not start coding until you think of a simple algorithm.

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