/* Symbol table manager for Bison,
- Copyright (C) 1984, 1989, 2000 Free Software Foundation, Inc.
+ Copyright 1984, 1989, 2000 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
return k % TABSIZE;
}
+/*--------------------------------------------------------------.
+| Create a new symbol, named TAG, which hash value is HASHVAL. |
+`--------------------------------------------------------------*/
+
+static bucket *
+bucket_new (const char *tag, int hashval)
+{
+ bucket *res = XMALLOC (bucket, 1);
+
+ res->link = symtab[hashval];
+ res->next = NULL;
+ res->tag = xstrdup (tag);
+ res->type_name = NULL;
+ res->value = 0;
+ res->prec = 0;
+ res->assoc = right_assoc;
+ res->user_token_number = 0;
+ res->alias = NULL;
+ res->class = unknown_sym;
+
+ nsyms++;
+
+ return res;
+}
+
void
tabinit (void)
}
+/*----------------------------------------------------------------.
+| Find the symbol named KEY, and return it. If it does not exist |
+| yet, create it. |
+`----------------------------------------------------------------*/
+
bucket *
getsym (const char *key)
{
if (found == 0)
{
- nsyms++;
-
- bp = XCALLOC (bucket, 1);
- bp->link = symtab[hashval];
- bp->next = NULL;
- bp->tag = xstrdup (key);
- bp->class = unknown_sym;
+ bp = bucket_new (key, hashval);
if (firstsymbol == NULL)
{