+
+/*----------------------------------.
+| Whether S is a valid identifier. |
+`----------------------------------*/
+
+static bool
+is_identifier (uniqstr s)
+{
+ static char const alphanum[26 + 26 + 1 + 10] =
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "_"
+ "0123456789";
+ if (!s || ! memchr (alphanum, *s, sizeof alphanum - 10))
+ return false;
+ for (++s; *s; ++s)
+ if (! memchr (alphanum, *s, sizeof alphanum))
+ return false;
+ return true;
+}
+
+
+/*-----------------------------------------------.
+| Get the identifier associated to this symbol. |
+`-----------------------------------------------*/
+uniqstr
+symbol_id_get (symbol const *sym)
+{
+ aver (sym->user_token_number != USER_NUMBER_HAS_STRING_ALIAS);
+ if (sym->alias)
+ sym = sym->alias;
+ return is_identifier (sym->tag) ? sym->tag : 0;
+}
+
+
+/*------------------------------------------------------------------.
+| Complain that S's WHAT is redeclared at SECOND, and was first set |
+| at FIRST. |
+`------------------------------------------------------------------*/
+
+static void
+symbol_redeclaration (symbol *s, const char *what, location first,
+ location second)
+{
+ unsigned i = 0;
+ complain_indent (&second, complaint, &i,
+ _("%s redeclaration for %s"), what, s->tag);
+ i += SUB_INDENT;
+ complain_indent (&first, complaint, &i,
+ _("previous declaration"));
+}
+
+static void
+semantic_type_redeclaration (semantic_type *s, const char *what, location first,
+ location second)
+{
+ unsigned i = 0;
+ complain_indent (&second, complaint, &i,
+ _("%s redeclaration for <%s>"), what, s->tag);
+ i += SUB_INDENT;
+ complain_indent (&first, complaint, &i,
+ _("previous declaration"));
+}
+
+
+
+/*-----------------------------------------------------------------.
+| Set the TYPE_NAME associated with SYM. Does nothing if passed 0 |
+| as TYPE_NAME. |
+`-----------------------------------------------------------------*/