- sprintf (buf, "@%d", ++gensym_count);
- sym = getsym (buf, location);
- sym->class = nterm_sym;
- sym->number = nvars++;
- return sym;
+ head.next = merge_functions;
+ for (syms = &head, n = 1; syms->next != NULL; syms = syms->next, n += 1)
+ if (strcmp (name, syms->next->name) == 0)
+ break;
+ if (syms->next == NULL)
+ {
+ syms->next = XMALLOC (merger_list, 1);
+ syms->next->name = xstrdup (name);
+ syms->next->type = xstrdup (type);
+ syms->next->next = NULL;
+ merge_functions = head.next;
+ }
+ else if (strcmp (type, syms->next->type) != 0)
+ warn_at (loc, _("result type clash on merge function %s: `%s' vs. `%s'"),
+ name, type, syms->next->type);
+ return n;
+}
+
+/*--------------------------------------.
+| Free all merge-function definitions. |
+`--------------------------------------*/
+
+void
+free_merger_functions (void)
+{
+ merger_list *L0;
+ if (! glr_parser)
+ return;
+ L0 = merge_functions;
+ while (L0 != NULL)
+ {
+ merger_list *L1 = L0->next;
+ free (L0);
+ L0 = L1;
+ }