summaryrefslogtreecommitdiff
path: root/utils/Burg/symtab.c
blob: 3ecab2fc5ff0ac311682f6da14643cab0f040626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
char rcsid_symtab[] = "$Id$";

#include <stdio.h>
#include <string.h>
#include "b.h"
#include "fe.h"

static List symtab;

Symbol
newSymbol(name) char *name;
{
	Symbol s;

	s = (Symbol) zalloc(sizeof(struct symbol));
	assert(s);
	s->name = name;
	return s;
}

Symbol
enter(name, new) char *name; int *new;
{
	List l;
	Symbol s;

	*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;
}