2002-09-17 23:03:30 +00:00
|
|
|
char rcsid_symtab[] = "$Id$";
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "b.h"
|
|
|
|
#include "fe.h"
|
|
|
|
|
|
|
|
static List symtab;
|
|
|
|
|
|
|
|
Symbol
|
|
|
|
newSymbol(name) char *name;
|
|
|
|
{
|
2005-04-22 04:13:13 +00:00
|
|
|
Symbol s;
|
2002-09-17 23:03:30 +00:00
|
|
|
|
2005-04-22 04:13:13 +00:00
|
|
|
s = (Symbol) zalloc(sizeof(struct symbol));
|
|
|
|
assert(s);
|
|
|
|
s->name = name;
|
|
|
|
return s;
|
2002-09-17 23:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Symbol
|
|
|
|
enter(name, new) char *name; int *new;
|
|
|
|
{
|
2005-04-22 04:13:13 +00:00
|
|
|
List l;
|
|
|
|
Symbol s;
|
2002-09-17 23:03:30 +00:00
|
|
|
|
2005-04-22 04:13:13 +00:00
|
|
|
*new = 0;
|
|
|
|
for (l = symtab; l; l = l->next) {
|
|
|
|
s = (Symbol) l->x;
|
|
|
|
if (!strcmp(name, s->name)) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*new = 1;
|
|
|
|
s = newSymbol(name);
|
|
|
|
symtab = newList(s, symtab);
|
|
|
|
return s;
|
2002-09-17 23:03:30 +00:00
|
|
|
}
|