Due by 11:59pm 11/09/2010
This is an extra-credit assignment.
In this project, you are to design and write an extensible scanner that can be extended without changing the base code. You will make heavy use of object-oriented design (see Recommended reading at the end of this page).
The first step is to write the base code for Token. In the base code, a Token is either an ID or a List of Tokens. Each token support a print() operation and a clone() operation. In the second step, a new token Symbol and a new method length() are added without changing the code of ID, List, and print(). The specific requirements are
- The base code should not know the exact name and interface of the extensions. You may add the two extensions Symbol and length() in any order but the base code should not know the name and interface of the first addition, nor should the first addition know the name and interface of the second addition.
- The extensions should not require any change to the base code. The second extension should not change the code of the first extension.
- Any program that uses the base tokens should not require any change to use the extended tokens and should be able to use the new token type and function.
Assignment organization
- This is a group project with three people. Talk to the instructor if you do not have a three-people group. One member writes the code for basic tokens. The other two write the two extensions. All three write a test program that uses the basic tokens and the extensions. Each person should write his or her part of the code in a program file separate from others. All three write a single written report. Group discussion and group work are intended part of this assignment.
- Turn in a written report for grading.
- (50 out of 100 points) The design of extensible token classes. You may receive partial credits for a design partially but not fully extensible.
- (10 out of 100 points) Extension of a new token.
- (10 out of 100 points) Extension of a new function.
- (20 out of 100 points) Implementation of the extensible tokens in either C++ or Java. Talk to the instructor if you want to used a different language. Compile and test your program. Submit the report and the source files of the token classes and the test
- (30 out of 100 points) The description of the design, implementation, and testing, which should be complete, clear, and concise.
- A single grade will be assigned to each group. The grade is the same for all members in the group.
Recommended reading
Synthesizing Object-Oriented and Functional Design to Promote Re-Use. Krishnamurthi, Felleisen and Friedman, Technical report TR 98-299, Rice University, 1998. (Local copy in postscript and pdf)
Design Patterns: Elements of Reusable Object-Oriented Software, Gamma, Helm, Johnson, and Vlissides, Addision-Wesley, 1995. Read the section on Visitor pattern, pp. 331-344. The instructor has a copy of the book that you can borrow for a short period of time (so that other groups can use it).
Thinking in C++. Eckel, Prentice Hall, 1995. (Use it as a C++ reference book, it contains clear explanations and concise examples). The instructor has a copy of the book that you can borrow for a short period of time (so that other groups can use it).
What/When/Where to Submit
Turn in your report of your design and code in project_code/ext_scanner/user_ids by 11:59pm 11/09/2010. The user_ids should include everyone in the team.