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"));
}
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;
}
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)
/* 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);
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;
}
}
return true;
}
else /* this->class == token_sym */
- {
- if (this->number == NUMBER_UNDEFINED)
- abort ();
- }
+ assert (this->number != NUMBER_UNDEFINED);
symbols[this->number] = this;
return true;
`----------------------------------------------------------------*/
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);
}
+/*----------------------------------------------------------------.
+| 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. |