* src/symtab.c (bucket_new): New function.

(getsym): Use it.
* src/output.c (output_short_table): New argument to display the
comment associated with the table.
Adjust dependencies.
(output_gram): Use it.
(output_rule_data): Nicer output layout for YYTNAME.
This commit is contained in:
Akim Demaille
2000-10-16 18:10:46 +00:00
parent f282676b7e
commit 1e9798d569
5 changed files with 128 additions and 99 deletions

View File

@@ -43,6 +43,31 @@ hash (const char *key)
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)
@@ -54,6 +79,11 @@ tabinit (void)
}
/*----------------------------------------------------------------.
| Find the symbol named KEY, and return it. If it does not exist |
| yet, create it. |
`----------------------------------------------------------------*/
bucket *
getsym (const char *key)
{
@@ -75,13 +105,7 @@ 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)
{