Homework 3 - Stacks

Due: Monday April 21, 2008 at 5:00pm

For this assignment, you will implement the linked node template class version of the Stack class. To test your implementation, your main program will check a C/C++ source file to see if it has matching parentheses and curly brackets. To do this, you will use stacks to hold the opening characters and match them to the closing characters. Your main program should prompt the user for a filename, open that file and read it in. Parse each character in the file looking for the opening and closing characters. Only parse the opening and closing characters if they are "bare" and not strings or characters, that is, parse ( but do not parse "(" or '('. If the parentheses and curly brackets all match, print out that the file is correct. Otherwise, print out whichever of the following apply: too many opening parentheses, too many closing parentheses, too many opening curly brackets or too many closing curly brackets. Your program should then loop back and ask for another filename. The program will exit when the user enters a blank filename or the command "quit".