CS
3100
Fall 2008
Lab 1
Due Wednesday, September 24
Expression Checker
Based on an assignment created by Dr. Sarraille and
Problem 6 in Chapter 5 of our text book.
Assignment:
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.
Output:
The program writes all its output to standard output. First the program
writes a heading/greeting message and prompts the user to enter the
strings. 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.
Discussion of Processing:
The following rule defines a well formed expression:
<word>
= <dot>|
<dash> <word> |
<word> <dot>
<dot> = .
<dash> = -
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 one of the exercises in chapter 5 of
Carrano. 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 Appendix A of Carrano (Review of C++ Fundamentals) for
details.
Testing:
You need
to create a test suite with good data and code coverage.
What To Turn In:
One can solve this
problem with a very small program (e.g. just two functions,
including main). Do not start coding until you think of a simple
algorithm.
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 hard copy of your final version of the program source
code,
and
- a hard copy 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.
- Upload to the homework
submission system before midnight on the due date:
Your final source code (example
format) and your test script. I will compile and test your programs
on the suns in the lab.