/**************************** Listing 1 ****************************/ /******* *******/ /******* Add this code to the declarations section of yref2.y, *******/ /******* between the %{ and %} symbols *******/ /******* *******/ /*********************************************************************/ struct symlist /* Linked list for storing line numbers */ { int line; /* Line number for this instance */ int decl; /* Declaration = 1, reference = 0 */ struct symlist *next; /* Pointer to next instance */ }; struct tnode { char *word; /* Identifier */ int count; /* Total instances */ struct symlist *first; /* Pointer to beginning of line list */ struct symlist *current; /* Pointer to most recent line instance */ struct tnode *left; /* Pointer to left node in tree */ struct tnode *right; /* Pointer to right node in tree */ }; struct tnode *root; int yn_decl = 0; /* Declaration = 1, reference = 0 */ struct tnode *addtree(struct tnode *, char *); void treeprint(struct tnode *); void listprint(struct symlist *, int ); struct tnode *talloc(void); struct symlist *lalloc(void);