CISC220, Summer 2006, Project 5
Introduction
This project is a continuation of Project 4 on HTML Tag Matching
As we discussed in lecture, you can use a stack to solve the problem of checking open and close tags in HTML for "proper nesting". Open tags are pushed onto the stack. Close tags cause us to pop the top of the stack, and check for a match. If the close tag and the top of the stack doesn't match, or if the stack has nothing to be popped we return a failure. We also return a failure if the stack is not empty when we hit end of file.
In Project 4, you did test-driven development of two classes:
- HTMLTag_C, a class to represent HTML tags such as <html> <head> <title> <body> <h1> <p>, etc., along with the line number and character number where they appear in an input stream.
- HTMLTagStack_C, a class that allows HTMLTag_C objects to be pushed and popped from a stack.
In Project 5, you use these classes to solve the problem
Project 5 will use the classes you developed to write a program that accepts HTML input, and either prints "ok", or gives a report of one of three kinds of errors that may be encountered:
- A mismatch between a close tag and the open tag at the top of the stack
- A close tag, encountered when the stack is empty (i.e. there is no open tag to match this close tag with)
- An open tag with no close tag (encountered when we reach end of file with a non-empty stack)
More about what you will do in Project 5
I am providing you with two files:
- HTMLTagMatcher.h, which you may modify if you need to (but you should only modify the private part, not the public part!)
- HTMLTagMatcherTest.cc, which is incomplete (in particular, you need to add more tests!)
Those files can be found at:
- The following directory on strauss:
/www/htdocs/CIS/220/pconrad/06J/work/proj/proj5
- The proj5 directory on the web site
These represent the interface to an HTMLTagMatcher_C class (similar to the Tokenizer_C class we covered in lecture... see the lecture notes and code from 07.24,07.25,07.26 and 07.27)
What to do
-
add tests to HTMLTagMatcherTest.cc so that it tests several cases ALL three errors, plus several "good" HTML files
- To earn full credit here, you need to be kind of "thorough" in your testing. Suppose that you are really trying to "break" the code, and really come up with some good tests.
- We might do a little "duel" and have you run YOUR test program on someone else's code to see if you can break it. If you break someone else's submission, but (a) their own tests passed and (b) your program passes your own tests, then you'll get some extra credit, plus bragging rights.
- write the .cc files for HTMLTagMatcher_C (at first, you should just write stubs, so that the tests fail). Here is where you might need to add code to the private part of HTMLTagMatcher.h to add private member functions, data members, etc. But don't change the interface to HTMLTagMatcher_C (i.e the public part).
- write a Makefile to compile and link the project, and run your tests
- now fix the HTMLTagMatcher.cc file so that it passes all the tests
- write a separate main program in a file matchTags.cc that will take a filename on the command line, open it, and actually parse the HTML in that file (you can use the tokenize.cc program from the lecture notes of 07.24,07.25,07.26 and 07.27 as a model.) Include error checking for your command line parameters, opening the file, etc.
- write four HTML files, input1.html, input2.html, input3.html and input4.html, that illustrate all four behaviors of your class, i.e.
- input1.html shows error 1 (mismatched tags)
- input2.html shows error 2 (close tag with no open tag)
- input3.html shows error 3 (open tag with no close tag)
- input4.html parses ok
- make a script that lists all your code, all your .html sample input files, and your Makefile, then shows a clean compile (make clean, make all), and shows the output of running your tests, and running your matchTags program on all four sample .html files.
Special Notes
Pair Programming
Pair Programming is an option for this assignment. It is not required---you are free to work alone if you prefer.
See the comments on the Wiki page: http://jaguar.cis.udel.edu:8051/220wiki/Wiki.jsp?page=06J.Proj5 for information about doing Pair Programming on this project.
What you can change, and what you should not change
- You should not change the public interface to the HTMLTagMatcher_C class, or the RunTests_C class. That way, it should be possible for your HTMLTagMatcherTest.cc program to be used with someone else's HTMLTagMatcher_C implementation.
- private parts of all classes are fair game for adjustment.
- check with your instructor if you are unsure.
Grading:
-
add tests to HTMLTagMatcherTest.cc (20%)
-
write the .cc files for HTMLTagMatcher_C (20%)
- write a Makefile to compile and link the project, and run your tests (10%)
- now fix the HTMLTagMatcher.cc file so that it passes all the tests (points included in part 2 above)
- write a separate main program in a file matchTags.cc (10%---also see item 6)
- write four HTML files, input1.html, input2.html, input3.html and input4.html, that illustrate all four behaviors of your class (20%---5% each for .html file, and correctness of output of matchTags.cc for that file)
- input1.html shows error 1 (mismatched tags)
- input2.html shows error 2 (close tag with no open tag)
- input3.html shows error 3 (open tag with no close tag)
- input4.html parses ok
- make a script that lists all your code, all your .html sample input files, and your Makefile, then shows a clean compile (make clean, make all), and shows the output of running your tests, and running your matchTags program on all four sample .html files. (10% for correctness of script file)
Also, 10% for general correctness of submission, following directions, etc.
Total: 100%
End of file proj5.html, for Project 5, CISC220, 06J