
260 Compilers – Principles and Practice
8.8.9 Utility Functions Used
int tcount = 0;
int lcount = 0;
int mcount = 0;
char *tokens[] = {"float","int","string","UNDEF", 0};
char *tokname(int tok){
return strdup(tokens[tok-VAR]);
}
Symbol * tree_root(char *label){
Symbol *np;
np = (Node *)malloc(sizeof(Node));
if(np == NULL) exit(-1);
np->link[0] = NULL; // ptr first child (if any)
np->link[1] = NULL; // ptr next sibling (if any)
np->w.S = (char *)malloc(strlen(label)+1);
strcpy(np->w.S, label); // node label
return np;
}
8.9 Real-life: Intermediate Codes of GNU gcc
GCC – GNU compiler collection (previously expanded as GNU C compiler), gcc/ccl ...