From e77a0b69d06145878c5ba474b1ec0293e6015a18 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Thu, 9 May 1996 07:27:43 +0000 Subject: [PATCH] Multiple local attributes values supported. --- retrieval/d1_absyn.c | 63 +++++++++++++++++++++++++++++++++++++------------ retrieval/d1_attset.c | 35 +++++++++++++++++++++------ 2 files changed, 76 insertions(+), 22 deletions(-) diff --git a/retrieval/d1_absyn.c b/retrieval/d1_absyn.c index 349821d..a708df6 100644 --- a/retrieval/d1_absyn.c +++ b/retrieval/d1_absyn.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_absyn.c,v $ - * Revision 1.4 1996-05-01 12:45:28 quinn + * Revision 1.5 1996-05-09 07:27:43 quinn + * Multiple local attributes values supported. + * + * Revision 1.4 1996/05/01 12:45:28 quinn * Support use of local tag names in abs file. * * Revision 1.3 1995/11/01 16:34:55 quinn @@ -158,10 +161,11 @@ data1_absyn *data1_read_absyn(char *file) { data1_element *new; int i; - char path[512], name[512], att[512], *p; + char path[512], name[512], termlists[512], *p; int type, value; + data1_termlist **tp; - if (sscanf(args, "%s %s %s", path, name, att) < 3) + if (sscanf(args, "%s %s %s", path, name, termlists) < 3) { logf(LOG_WARN, "Bad # of args to elm in %s: '%s'", file, args); @@ -189,7 +193,8 @@ data1_absyn *data1_read_absyn(char *file) abort; new->next = new->children = 0; new->tag = 0; - new->att = 0; + new->termlists = 0; + tp = &new->termlists; ppl[level] = &new->next; ppl[level+1] = &new->children; @@ -228,10 +233,10 @@ data1_absyn *data1_read_absyn(char *file) return 0; } - if (*att == '!') - strcpy(att, name); - if (*att == '-') - new->att = 0; + /* parse termList definitions */ + p = termlists; + if (*p == '-') + new->termlists = 0; else { if (!res->attset) @@ -240,16 +245,44 @@ data1_absyn *data1_read_absyn(char *file) fclose(f); return 0; } - if (!(new->att = data1_getattbyname(res->attset, att))) + do { - logf(LOG_WARN, "Couldn't find att '%s' in attset", att); - fclose(f); - return 0; + char attname[512], structure[512]; + int r; + + if (!(r = sscanf(p, "%511[^:,]:%511[^,]", attname, + structure))) + { + logf(LOG_WARN, "Syntax error in termlistspec in %s", + file); + fclose(f); + return 0; + } + if (*attname == '!') + strcpy(attname, name); + *tp = xmalloc(sizeof(**tp)); + if (!((*tp)->att = data1_getattbyname(res->attset, + attname))) + { + logf(LOG_WARN, "Couldn't find att '%s' in attset", + attname); + fclose(f); + return 0; + } + if (r < 2) /* is the structure qualified? */ + (*tp)->structure = DATA1S_word; + else if (!data1_matchstr(structure, "w")) + (*tp)->structure = DATA1S_word; + else if (!data1_matchstr(structure, "p")) + (*tp)->structure = DATA1S_phrase; + + (*tp)->next = 0; + tp = &(*tp)->next; } + while ((p = strchr(p, ',')) && *(++p)); } - if (!(new->name = xmalloc(strlen(name)+1))) - abort(); - strcpy(new->name, name); + + new->name = xstrdup(name); } else if (!strcmp(cmd, "name")) { diff --git a/retrieval/d1_attset.c b/retrieval/d1_attset.c index e179415..04401c5 100644 --- a/retrieval/d1_attset.c +++ b/retrieval/d1_attset.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_attset.c,v $ - * Revision 1.4 1996-02-21 15:23:36 quinn + * Revision 1.5 1996-05-09 07:27:43 quinn + * Multiple local attributes values supported. + * + * Revision 1.4 1996/02/21 15:23:36 quinn * Reversed fclose and return; * * Revision 1.3 1995/12/13 17:14:26 quinn @@ -88,19 +91,37 @@ data1_attset *data1_read_attset(char *file) *args = '\0'; if (!strcmp(cmd, "att")) { - int num, local, rr; - char name[512]; + int num, rr; + char name[512], localstr[512]; data1_att *t; + data1_local_attribute *locals; - if ((rr = sscanf(args, "%d %s %d", &num, name, &local)) < 2) + if ((rr = sscanf(args, "%511d %s %511s", &num, name, localstr)) < 2) { logf(LOG_WARN, "Not enough arguments to att in '%s' in %s", args, file); fclose(f); return 0; } - if (rr < 3) - local = num; + if (rr < 3) /* no local attributes given */ + { + locals = xmalloc(sizeof(*locals)); + locals->local = num; + locals->next = 0; + } + else /* parse the string "local{,local}" */ + { + char *p = localstr; + data1_local_attribute **ap = &locals; + do + { + *ap = xmalloc(sizeof(**ap)); + (*ap)->local = atoi(p); + (*ap)->next = 0; + ap = &(*ap)->next; + } + while ((p = strchr(p, ',')) && *(++p)); + } if (!(t = *attp = xmalloc(sizeof(*t)))) abort(); t->parent = res; @@ -108,7 +129,7 @@ data1_attset *data1_read_attset(char *file) abort(); strcpy(t->name, name); t->value = num; - t->local = local; + t->locals = locals; t->next = 0; attp = &t->next; } -- 1.7.10.4