(rev. 02/08/2008)

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


INPUT:

The program must read, from standard input, an arbitrary series of zero or more strings. Strings are to be separated by white space. There is to be no other input to the program. sample input illustrates the kind of input I will use to test your program.


OUTPUT:

The program must write all output to standard output. First the program must write a heading/greeting message. Next, for each input string, the program must go to a new line of the output, echo (write) the input string to standard output, go to a new line again, and print 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> = Let | Und | <expression>Let | <expression>Und | <expression>Dig

Your solution to this problem must be "recursive" -- it must use a recursive function to test the strings. Design the function to input a string and output 'true' or 'false' - telling whether or not the string is an expression.

In class, we can discuss solutions to some problems that are similar to this one. That should give you some useful ideas for writing your program. In your solution code, you may want to use the substr method of the string object. See page 840 in Appendix A of Carrano (Review of C++ Fundamentals) for details.


TESTING:

Your test script will count for about 15% of your grade on this program. We'll have a discussion of testing requirements 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. Do not start coding until you think of a simple algorithm. If you are considering a solution that is complicated, then you are not using the right approach.

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:

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