X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmetadata%2Fcreate_V7_mowgli%2FMETADATA%2Fsthandler.c;h=0f32e07c179c6a0cf25a86b66bd79e19eb10455d;hb=89262281b6e83bd2321150f81f1a0583645eb0c8;hp=963200038beda7a83ff051fd4205f16a9f22cfc0;hpb=0e6b8620b9c128c3f256c00b422cee7708321171;p=helm.git diff --git a/helm/metadata/create_V7_mowgli/METADATA/sthandler.c b/helm/metadata/create_V7_mowgli/METADATA/sthandler.c index 963200038..0f32e07c1 100644 --- a/helm/metadata/create_V7_mowgli/METADATA/sthandler.c +++ b/helm/metadata/create_V7_mowgli/METADATA/sthandler.c @@ -67,9 +67,16 @@ /* 3. Types. */ /****************************************************************/ +struct int_list { + int val; + struct int_list *next; + }; + struct st_bucket { char *id; - /* identifier */ + /* identifier */ + int main_depth; + struct int_list *depths; struct st_bucket *next_st_bucket; /* next bucket in the list */ struct st_bucket *all_next; @@ -83,7 +90,12 @@ struct st_bucket *dictionary[DICTSIZE]; /* pointers to bucket lists */ /****************************************************************/ -/* 4. Definitions of functions to be exported. */ +/* 4. Local functions. */ +/****************************************************************/ +struct int_list *add(struct int_list *,int); + +/****************************************************************/ +/* 5. Definitions of functions to be exported. */ /****************************************************************/ struct st_bucket *all; @@ -105,10 +117,11 @@ void init_symbol_table() /* The bucket associated with the given identifier */ /* becomes the first one in its list. */ -search_bucket(id, where) +search_bucket(id, where, depth) char *id; /* identifier */ int where; + int depth; { int dict_index; /* value returned by the */ @@ -120,8 +133,8 @@ search_bucket(id, where) struct st_bucket *st; /* apply the hash function */ - dict_index = hash_pjw(id); - /* printf( "%d\n", dict_index); */ + dict_index = hash_pjw(id); + /* fprintf(stderr,"%d\n", dict_index); */ /* scan the bucket list indicated by the hash function */ prev = curr = dictionary[dict_index]; @@ -134,12 +147,17 @@ search_bucket(id, where) /* the identifier is not in the list */ { allocate_bucket(&st,id,where); + if (where == MAINCONCL) + st->main_depth = depth; + else if (where == MAINHYP) + st->depths = add(st->depths,depth); move_bucket(st,dict_index); return NOTFOUND; } else - /* printf("uno=%s\n", id); - printf("st=%s\n", curr->id); */ + /* + printf("uno=%s\n", id); + printf("st=%s\n", curr->id); fflush(stdout) */ /* the identifier is already in the list */ { @@ -147,6 +165,10 @@ search_bucket(id, where) curr->pos[where] = 1; if (where >= 1) curr->pos[INBODY] = 0; /* it will never be set again to 1 */ + if (where == MAINHYP) + curr->depths=add(curr->depths,depth); + else if (where == MAINCONCL) + curr->main_depth = depth; if (prev != curr) /* the identifier is not in the first position */ { @@ -158,17 +180,27 @@ search_bucket(id, where) } } -print_all() +print_all(about,outrel,outsort) + char *about; + FILE *outrel, + *outsort; { + int i; struct st_bucket *curr; curr = all; - while (curr != NULL) { for (i = 0; i < 5; ++i) - if (curr->pos[i] == 1) - print_one(curr->id,i); + if ((curr->pos[i]) == 1) + { + if (i == MAINHYP) + print_mainhyp(about,outrel,outsort,curr->id,curr->depths); + else if (i == MAINCONCL) + print_mainconcl(about,outrel,outsort,curr->id,curr->main_depth); + else + print_one(curr->id,i); + } curr = curr->all_next; } } @@ -178,13 +210,135 @@ print_all() /* 5. Definitions of functions local to the module. */ /****************************************************************/ +struct int_list *add(l,m) + struct int_list *l; + int m; +{ + struct int_list *curr; + /* scan the list looking for m */ + curr = l; + while ((curr != NULL) && (m != (curr->val))) + curr = curr->next; + if (curr == NULL) + /* m is not in the list */ + { + curr = (struct int_list *)malloc(sizeof(struct int_list)); + curr->val = m; + curr->next = l; + return curr; + } + else + return l; + +} + +print_mainhyp(about,outrel,outsort,uri,l) + char *about; + FILE *outrel, + *outsort; + char *uri; + struct int_list *l; +{ + struct int_list *curr; + curr = l; + if (!strcmp(uri,"Rel")) + { + /* scan the list */ + while (curr != NULL) + { + fprintf(outrel,"\t\n"); + fprintf(outrel,"\t\t"); + fprintf(outrel,"\n\t\t\t\t"); + fprintf(outrel,"\n\t\t\t\t%d",curr->val); + fprintf(outrel,"\n\t\t\n"); + fprintf(outrel,"\t\n"); + curr = curr->next; + } + } + else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) || + (!strcmp(uri,"Set"))) + { + /* scan the list */ + while (curr != NULL) + { + fprintf(outsort,"\t\n"); + fprintf(outsort,"\t\t"); + fprintf(outsort,"\n\t\t\t\t"); + fprintf(outsort,"\n\t\t\t\t",uri); + fprintf(outsort,"\n\t\t\t\t%d",curr->val); + fprintf(outsort,"\n\t\t\n"); + fprintf(outsort,"\t\n"); + curr = curr->next; + } + } + else + { + /* scan the list */ + while (curr != NULL) + { + printf("\t\t"); + printf("\n\t\t\t\t"); + printf("\n\t\t\t\t%d",curr->val); + printf("\n\t\t\t\t",uri); + printf("\n\t\t\n"); + curr = curr->next; + } + } +} + +print_mainconcl(about,outrel,outsort,uri,depth) + char *about; + FILE *outrel, + *outsort; + char *uri; + int depth; + +{ + if (!strcmp(uri,"Rel")) + { + fprintf(outrel,"\t\n"); + fprintf(outrel,"\t\t"); + fprintf(outrel,"\n\t\t\t\t"); + fprintf(outrel,"\n\t\t\t\t%d",depth); + fprintf(outrel,"\n\t\t\n"); + fprintf(outrel,"\t\n"); + } + else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) || + (!strcmp(uri,"Set"))) + { + fprintf(outsort,"\t\n"); + fprintf(outsort,"\t\t"); + fprintf(outsort,"\n\t\t\t\t"); + fprintf(outsort,"\n\t\t\t\t",uri); + fprintf(outsort,"\n\t\t\t\t%d",depth); + fprintf(outsort,"\n\t\t\n"); + fprintf(outsort,"\t\n"); + } + else + { + printf("\t\t"); + printf("\n\t\t\t\t"); + printf("\n\t\t\t\t%d",depth); + printf("\n\t\t\t\t",uri); + printf("\n\t\t\n"); + } +} // dome: cambiata per usare il modello con position print_one(uri,pos) char *uri; int pos; { - printf("\t\t\n\t\t\t\n\t\t\t\t"); + printf("\t\t"); + printf("\n\t\t\t\t\n\t\t\t\t%s\n\t\t\t\n\t\t\n", uri); + printf("\"/>\n\t\t\t\t\n\t\t\n", uri); } /* The following function allocates a bucket for an identifier. */ @@ -213,6 +367,8 @@ allocate_bucket(st, id, where) *st = (struct st_bucket *)malloc(sizeof(struct st_bucket)); (*st)->id = (char *)malloc(sizeof('a')*(strlen(id) + 1)); strcpy((*st)->id,id); + (*st)->main_depth = 0; + (*st)->depths = NULL; (*st)->next_st_bucket = NULL; (*st)->all_next = all; all = *st; @@ -259,3 +415,4 @@ hash_pjw(id) +