(Latest Revision:
09/01/2005)
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 252-255 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 846 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. If you just copy my sample input and make a script with that,
unfortunately 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. Do 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:
- 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. It is hard to keep
track. 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 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.