X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmetadata%2Fcreate_V7_mowgli%2FMETADATA%2Fmeta_lex_ind.l;h=31e1416f0fbf6e833adc003e4da89d9d06e46589;hb=4faf0e37e7019de16dd6862bb34d84f799a2a230;hp=6d09578f90a94a7673efaa7e7d6b81c03485ca5c;hpb=0e6b8620b9c128c3f256c00b422cee7708321171;p=helm.git diff --git a/helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l b/helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l index 6d09578f9..31e1416f0 100644 --- a/helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l +++ b/helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l @@ -38,7 +38,9 @@ %{ #include #include -#include "sthandler_ind.h" +#include +#include +#include "sthandler.h" %} /***************************************************************/ @@ -50,6 +52,7 @@ #define CONST 1 #define MUTIND 2 #define MUTCONSTRUCT 3 +#define SORT 4 #define INBODY 0 #define MAINHYP 1 @@ -65,65 +68,47 @@ int where = NOWHERE; int found = NOTFOUND; -int position = INTYPE; +int position = INBODY; int first_child = HERE; int skip = 0; // boolean to skip the insertion of a URI int no_open_source =0; +int spine_depth = 0; +int depth = 0; int tmp_n; -int inductive_type =0; +int inductive_type = 0; int constructor = 0; int deep_type = 0; char sep = '"'; char *xpointer = "#xpointer(1/"; char *uri; char *tmp; -char *filename; -char *file_uri; -char *inductive_uri; -char *filename_prefix; -char *file_uri_prefix; - +char *source_uri; +char *source_uri_prefix; +PGconn *conn; %} -/*%x deeptype*/ - - /***************************************************************/ /* 3. Regular definitions. */ /***************************************************************/ uri [^"]+ -digits [0-9]+ +digits [0-9]+ +value [^"]+ /***************************************************************/ /* 4. Rules. */ /***************************************************************/ -/* -"" { - BEGIN(deeptype); - deep_type++; - } - -"" { - deep_type++; - } - -"" { - deep_type--; - if (deeptype == 0) BEGIN(0); - } - -.|\n { - } -*/ %% "" { tmp = (char *)malloc(sizeof('a')*128); - strcpy(filename,filename_prefix); - fprintf(stderr,"tre"); - strcpy(file_uri,file_uri_prefix); - sprintf(tmp,",%d.xml", inductive_type); - fprintf(stderr,"quattro"); - strcat(filename,tmp); + strcpy(source_uri,source_uri_prefix); sprintf(tmp,"#xpointer(1/%d)", inductive_type); - strcat(file_uri,tmp); - fprintf(stderr,"cinque"); + strcat(source_uri,tmp); + /* fprintf(stderr,"cinque"); */ free(tmp); - print_file(); + print_all(source_uri,conn); + /* print_file(); */ } "" { tmp = (char *)malloc(sizeof('a')*128); - strcpy(filename,filename_prefix); - strcpy(file_uri,file_uri_prefix); - strcpy(inductive_uri,file_uri_prefix); - sprintf(tmp,",%d,%d.xml", inductive_type,constructor); - strcat(filename,tmp); + strcpy(source_uri,source_uri_prefix); sprintf(tmp,"#xpointer(1/%d/%d)",inductive_type,constructor); - strcat(file_uri,tmp); + strcat(source_uri,tmp); free(tmp); - print_file(); + print_all(source_uri,conn); + /* print_file(); */ } "" | -"" { if (position == INHYP) { no_open_source--; if (no_open_source == 0) - { position = INTYPE; - first_child = HERE; }; - }; + { + position = MAINHYP; + depth++; + first_child = HERE; + } + } + else if (position == MAINHYP) + { + position = INTYPE; + spine_depth++; + depth = 0; + first_child = HERE; + } } + .|\n { } "\n\n"); - fprintf(out,"\n"); - fprintf(out,"\t\n"); - print_all(out); - fprintf(out,"\t\n"); - fprintf(out,"\n"); - fclose(out); - } + struct stat buf; + + char *pghost, + *pgport, + *pgoptions, + *pgtty; + char *dbName; + + /* FILE *debug; */ + + PGresult *res; + + if (argc != 3) + { + fprintf(stderr, "Usage: meta_ind \n"); + exit(1); + } + + /* + * begin, by setting the parameters for a backend connection if the + * parameters are null, then the system will try to use reasonable + * defaults by looking up environment variables or, failing that, + * using hardwired constants + */ + + /* make a connection to the database */ + conn = PQconnectdb("user=helm dbname=mowgli"); + + /* + * check to see that the backend connection was successfully made + */ + if (PQstatus(conn) == CONNECTION_BAD) + { + fprintf(stderr, "Connection to database '%s' failed.\n", dbName); + fprintf(stderr, "%s", PQerrorMessage(conn)); + exit_nicely(conn); + } + + /* debug = fopen("/tmp/trace.out","w"); */ + /* PQtrace(conn, debug); */ + + source_uri = malloc((sizeof('a')*2000)); + source_uri_prefix=argv[1]; + /* fprintf(stderr,"qua"); */ + yyin = fopen(argv[2], "r"); + yylex(); + + return 0; } -search(uri,first_child,position) +search(uri,first_child,position,depth) char *uri; int first_child; int position; { - if (first_child == HERE) - { - if (position == INHYP) - found = search_bucket(uri,MAINHYP); - else if (position == INCONCL) - found = search_bucket(uri,MAINCONCL); - /* if (found == NOTFOUND) - printf( "pos = %d, uri = %s\n", MAINCONCL, uri); */ - } - else found = search_bucket(uri,position); - /* if (found == NOTFOUND) - printf( "pos = %d, uri = %s\n", position, uri); */ - } + if (position == MAINHYP) + { + if (first_child == HERE) + found = search_bucket(uri,MAINHYP,depth); + else + found = search_bucket(uri,INHYP,0); + } + else if (position == INCONCL) + { + if (first_child == HERE) + found = search_bucket(uri,MAINCONCL,depth); + else + found = search_bucket(uri,INCONCL,0); + } + + else + found = search_bucket(uri,position,depth); + if (found == NOTFOUND) + printf( "pos = %d, uri = %s\n", position, uri); +} + int yywrap() { return 1; } + + + +