X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/073f92889fed2bb511833920e841243a749223ca..dd60572a8b54ebc51421448f09f83f39bc0a4229:/src/symtab.c diff --git a/src/symtab.c b/src/symtab.c index 1f2c17ee..b71a3fba 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -108,7 +108,7 @@ static void redeclaration (symbol* s, const char *what, location first, location second) { complain_at (second, _("%s redeclaration for %s"), what, s->tag); - complain_at (first, _("first declaration")); + complain_at (first, _("previous declaration")); } @@ -158,7 +158,7 @@ symbol_printer_set (symbol *sym, const char *printer, location loc) if (printer) { if (sym->printer) - redeclaration (sym, "%printer", sym->destructor_location, loc); + redeclaration (sym, "%printer", sym->printer_location, loc); sym->printer = printer; sym->printer_location = loc; } @@ -223,8 +223,7 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) void symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) { - if (sym->class != token_sym) - abort (); + assert (sym->class == token_sym); if (sym->user_token_number != USER_NUMBER_UNDEFINED && sym->user_token_number != user_token_number) @@ -295,8 +294,7 @@ symbol_make_alias (symbol *sym, symbol *symval, location loc) /* sym and symval combined are only one symbol. */ nsyms--; ntokens--; - if (ntokens != sym->number && ntokens != symval->number) - abort (); + assert (ntokens == sym->number || ntokens == symval->number); sym->number = symval->number = (symval->number < sym->number) ? symval->number : sym->number; symbol_type_set (symval, sym->type_name, loc); @@ -389,8 +387,7 @@ symbol_pack (symbol *this) this->number = this->alias->number = 0; else { - if (this->alias->number == NUMBER_UNDEFINED) - abort (); + assert (this->alias->number != NUMBER_UNDEFINED); this->number = this->alias->number; } } @@ -399,10 +396,7 @@ symbol_pack (symbol *this) return true; } else /* this->class == token_sym */ - { - if (this->number == NUMBER_UNDEFINED) - abort (); - } + assert (this->number != NUMBER_UNDEFINED); symbols[this->number] = this; return true; @@ -505,12 +499,11 @@ symbols_new (void) `----------------------------------------------------------------*/ symbol * -symbol_get (const char *key, location loc) +symbol_from_uniqstr (const uniqstr key, location loc) { symbol probe; symbol *entry; - key = uniqstr_new (key); probe.tag = key; entry = hash_lookup (symbol_table, &probe); @@ -524,6 +517,18 @@ symbol_get (const char *key, location loc) } +/*----------------------------------------------------------------. +| Find the symbol named KEY, and return it. If it does not exist | +| yet, create it. | +`----------------------------------------------------------------*/ + +symbol * +symbol_get (const char *key, location loc) +{ + return symbol_from_uniqstr (uniqstr_new (key), loc); +} + + /*------------------------------------------------------------------. | Generate a dummy nonterminal, whose name cannot conflict with the | | user's names. |