(rev. 08/29/2015)

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 an arbitrary series of zero or more strings from standard input. (If you are writing in C++ you would use "cin statements" to read from standard input. The default standard input is the keyboard, but you can use unix redirection to make your program read from a prepared file of inputs.) Input strings are to be separated by white space. For example, you can enter them one per line. There is to be no other input to the program. The sample input illustrates the kind of input I will use to test your program.


OUTPUT:

The program must write all output to standard output. (If you are writing in C++ you would use "cout statements" to write 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, after processing all the input, the program prints an exit message and stops. There is no other output. If you are entering input at the keyboard, the program should stop reading input when you enter the end-of-file characater (cntrl-d).

This script shows the output produced in response to the sample input file.


DISCUSSION OF PROCESSING:

The following rule defines a well-formed expression:

<expr> = S | I(C)T(<expr>)

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 709-710 in Appendix A of Carrano (Review of C++ Fundamentals) for an overview of how to use C++ strings.


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. Never assume that sample inputs I give you with an assignment represent everything you need to test to make sure your program is correct.


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. If you don't think of a simple solution after the first day of working on it, ask me for help (please!). You can ask me privately if you want, but I do like to get some questions in class, so I can help more than one person at a time.

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.