2002-09-17 23:03:30 +00:00
|
|
|
char rcsid_string[] = "$Id$";
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "b.h"
|
|
|
|
#include "fe.h"
|
|
|
|
|
|
|
|
static StrTableElement newStrTableElement ARGS((void));
|
|
|
|
|
|
|
|
StrTable
|
|
|
|
newStrTable()
|
|
|
|
{
|
2005-04-22 04:13:13 +00:00
|
|
|
return (StrTable) zalloc(sizeof(struct strTable));
|
2002-09-17 23:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static StrTableElement
|
|
|
|
newStrTableElement()
|
|
|
|
{
|
2005-04-22 04:13:13 +00:00
|
|
|
return (StrTableElement) zalloc(sizeof(struct strTableElement));
|
2002-09-17 23:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dumpStrTable(t) StrTable t;
|
2005-04-22 04:13:13 +00:00
|
|
|
{
|
|
|
|
List e;
|
|
|
|
IntList r;
|
2002-09-17 23:03:30 +00:00
|
|
|
|
2005-04-22 04:13:13 +00:00
|
|
|
printf("Begin StrTable\n");
|
|
|
|
for (e = t->elems; e; e = e->next) {
|
|
|
|
StrTableElement el = (StrTableElement) e->x;
|
|
|
|
printf("%s: ", el->str);
|
|
|
|
for (r = el->erulenos; r; r = r->next) {
|
|
|
|
int i = r->x;
|
|
|
|
printf("(%d)", i);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf("End StrTable\n");
|
2002-09-17 23:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StrTableElement
|
|
|
|
addString(t, s, eruleno, new) StrTable t; char *s; int eruleno; int *new;
|
|
|
|
{
|
2005-04-22 04:13:13 +00:00
|
|
|
List l;
|
|
|
|
StrTableElement ste;
|
2002-09-17 23:03:30 +00:00
|
|
|
|
2005-04-22 04:13:13 +00:00
|
|
|
assert(t);
|
|
|
|
for (l = t->elems; l; l = l->next) {
|
|
|
|
StrTableElement e = (StrTableElement) l->x;
|
2002-09-17 23:03:30 +00:00
|
|
|
|
2005-04-22 04:13:13 +00:00
|
|
|
assert(e);
|
|
|
|
if (!strcmp(s, e->str)) {
|
|
|
|
e->erulenos = newIntList(eruleno, e->erulenos);
|
|
|
|
*new = 0;
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ste = newStrTableElement();
|
|
|
|
ste->erulenos = newIntList(eruleno, 0);
|
|
|
|
ste->str = (char *) zalloc(strlen(s) + 1);
|
|
|
|
strcpy(ste->str, s);
|
|
|
|
t->elems = newList(ste, t->elems);
|
|
|
|
*new = 1;
|
|
|
|
return ste;
|
2002-09-17 23:03:30 +00:00
|
|
|
}
|