next up previous
Next: Structure of the Output Up: Example Previous: Example

Statement of the problem to be solved

You need to classify a collection of several thousand words. There are no duplicate words in any class, but a given word may belong to more than one class. The classes have arbitrary names, and no two classes may have the same name.

A C program will manipulate the words and classes. Because of the application, classes will be relatively fluid. The customer expects that new words and classes will be added, and the classification of existing words changed, on the basis of experience and changing requirements. Nevertheless, the system design requires that the data be built into the C program at compile time.

The system designers have settled on an internal representation of the data involving an array for each class containing the words in that class as strings, an array containing the class names as strings, and an array containing the sizes of the classes as integers. The number of classes is also given. All of these data items are to be specified in a single header file. Here is an example of such a header file for a simple classification:


int NumberOfSets = 3;

char *NameOfSet[] = {

int SizeOfSet[] = {

char *SetOf_colors[] = {

char *SetOf_bugs[] = {

char *SetOf_verbs[] = {

char **ValuesOfSet[] = {
This macro is attached to a product file.

Although the meaning of the internal representation is straightforward, it is quite clear that making the necessary alterations will be a tedious and error-prone process. Any change requires compatible modifications of several arrays. For example, moving a word from one class to another means not only cutting and pasting the word itself, but also changing the sizes of both classes.

It would be simpler and safer to define the classification with a notation ideally suited to that task, and generate the header file from that definition. Here is an example of an obvious notation, defining the classification represented by the header file given above:


colors{red blue green}
bugs{ant spider fly moth bee}
verbs{crawl walk run fly}
This macro is attached to a product file.

next up previous
Next: Structure of the Output Up: Example Previous: Example