Extensible Token Project

Problem description

In this project, design and write an extensible token program so that other people can extend it without changing the base code.  You will make heavy use of polymorphism and inheritance to write in a style often known as"the visitor pattern" (see Recommended reading at the end of this page).

In this particular problem, assume that one starts with basic tokens ID and Number.  Each token has operations modify and print.  Then someone may want to add a new token type Symbol.  Someone else may want to add a new method length().  Can you design token classes in a way such that Symbol and length() can be added without changing the code of ID and Number.  The specific requirements are

Project organization

Recommended reading

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.  I have a copy of the book that you can borrow for a short period of time (so that other groups can use it).

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)

Thinking in C++. Eckel, Prentice Hall, 1995.  (Use it as a C++ reference book, it contains clear explanations and concise examples).  I have a copy of the book that you can borrow for a short period of time (so that other groups can use it).