+/*-----------------.
+| Print a symbol. |
+`-----------------*/
+
+#define SYMBOL_ATTR_PRINT(Attr) \
+ if (s->Attr) \
+ fprintf (f, " %s { %s }", #Attr, s->Attr)
+
+void
+symbol_print (symbol *s, FILE *f)
+{
+ fprintf (f, "\"%s\"", s->tag);
+ SYMBOL_ATTR_PRINT (type_name);
+ SYMBOL_ATTR_PRINT (destructor);
+ SYMBOL_ATTR_PRINT (printer);
+}
+
+#undef SYMBOL_ATTR_PRINT
+
+/*------------------------------------------------------------------.
+| Complain that S's WHAT is redeclared at SECOND, and was first set |
+| at FIRST. |
+`------------------------------------------------------------------*/
+
+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"));
+}
+
+
+/*-----------------------------------------------------------------.
+| Set the TYPE_NAME associated with SYM. Does nothing if passed 0 |
+| as TYPE_NAME. |
+`-----------------------------------------------------------------*/
+
+void
+symbol_type_set (symbol *sym, uniqstr type_name, location loc)
+{
+ if (type_name)
+ {
+ if (sym->type_name)
+ redeclaration (sym, "%type", sym->type_location, loc);
+ uniqstr_assert (type_name);
+ sym->type_name = type_name;
+ sym->type_location = loc;
+ }
+}
+
+
+/*------------------------------------------------------------------.
+| Set the DESTRUCTOR associated with SYM. Do nothing if passed 0. |
+`------------------------------------------------------------------*/
+
+void
+symbol_destructor_set (symbol *sym, const char *destructor, location loc)
+{
+ if (destructor)
+ {
+ if (sym->destructor)
+ redeclaration (sym, "%destructor", sym->destructor_location, loc);
+ sym->destructor = destructor;
+ sym->destructor_location = loc;
+ }
+}
+
+
+/*---------------------------------------------------------------.
+| Set the PRINTER associated with SYM. Do nothing if passed 0. |
+`---------------------------------------------------------------*/