1 /******************************************************************/
2 /* Copyright (C) 2000, HELM Team */
4 /* This file is part of HELM, an Hypertextual, Electronic */
5 /* Library of Mathematics, developed at the Computer Science */
6 /* Department, University of Bologna, Italy. */
8 /* HELM is free software; you can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation; either version */
11 /* 2 of the License, or (at your option) any later version. */
13 /* HELM is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
16 /* GNU General Public License for more details. */
18 /* You should have received a copy of the GNU General Public */
19 /* License along with HELM; if not, write to the Free Software */
20 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */
21 /* MA 02111-1307, USA. */
23 /* For details, see the HELM World-Wide-Web page, */
24 /* http://cs.unibo.it/helm/. */
25 /******************************************************************/
27 /***************************************************************/
29 /* Automatic Metadata Extractor */
30 /* First draft 11/12/2001, by Andrea Asperti */
31 /* more bugs added by domenico lordi on mon 12/17/2001 */
32 /***************************************************************/
34 /***************************************************************/
35 /* 1. Inclusion of header files. */
36 /***************************************************************/
41 #include "sthandler_ind.h"
44 /***************************************************************/
45 /* 2. Constants and Variables Definitions */
46 /***************************************************************/
52 #define MUTCONSTRUCT 3
68 int position = INTYPE;
69 int first_child = HERE;
70 int skip = 0; // boolean to skip the insertion of a URI
71 int no_open_source =0;
73 int inductive_type =0;
77 char *xpointer = "#xpointer(1/";
83 char *filename_prefix;
84 char *file_uri_prefix;
91 /***************************************************************/
92 /* 3. Regular definitions. */
93 /***************************************************************/
98 /***************************************************************/
100 /***************************************************************/
112 <deeptype>"</type>" {
114 if (deeptype == 0) BEGIN(0);
124 fprintf(stderr,"uno");
126 fprintf(stderr,"due");
133 "</arity>" { tmp = (char *)malloc(sizeof('a')*128);
134 strcpy(filename,filename_prefix);
135 fprintf(stderr,"tre");
136 strcpy(file_uri,file_uri_prefix);
137 sprintf(tmp,",%d.xml", inductive_type);
138 fprintf(stderr,"quattro");
139 strcat(filename,tmp);
140 sprintf(tmp,"#xpointer(1/%d)", inductive_type);
141 strcat(file_uri,tmp);
142 fprintf(stderr,"cinque");
147 "<Constructor" { init_symbol_table();
149 strcpy(inductive_uri,file_uri_prefix);
154 "</Constructor>" { tmp = (char *)malloc(sizeof('a')*128);
155 strcpy(filename,filename_prefix);
156 strcpy(file_uri,file_uri_prefix);
157 strcpy(inductive_uri,file_uri_prefix);
158 sprintf(tmp,",%d,%d.xml", inductive_type,constructor);
159 strcat(filename,tmp);
160 sprintf(tmp,"#xpointer(1/%d/%d)",inductive_type,constructor);
161 strcat(file_uri,tmp);
168 if ((position == INTYPE) ||
176 if (position == INHYP)
179 if (no_open_source == 0)
181 first_child = HERE; };
202 if (position == INTYPE) /* CONST on the spine */
208 if (position == INTYPE) /* MUTIND on the spine */
214 if (position == INTYPE) /* MUTCONSTRUCT on the spine */
216 where = MUTCONSTRUCT;
221 uri=(char *)malloc((sizeof('a')*200));
226 search(uri,first_child,position);
234 "noType=\""{digits} {
235 if ((where == MUTIND) || (where == MUTCONSTRUCT))
236 { strsep(&yytext,&sep);
237 tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
240 sprintf(tmp,"%d",tmp_n);
241 strcat(uri,"#xpointer(1/");
247 search(uri,first_child,position);
251 first_child = AFTER;};
254 "noConstr=\""{digits} {
255 if (where == MUTCONSTRUCT)
256 { strsep(&yytext,&sep);
257 tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
262 search(uri,first_child,position);
266 first_child = AFTER;};
272 /***************************************************************/
273 /* 6. Auxiliary functions. */
274 /***************************************************************/
276 main(int argc, char *argv[])
278 filename = malloc((sizeof('a')*2000));
279 file_uri = malloc((sizeof('a')*2000));
280 inductive_uri = malloc((sizeof('a')*2000));
281 filename_prefix=argv[1];
282 file_uri_prefix=argv[2];
283 fprintf(stderr,"qua");
284 yyin = fopen("tmp/inductive_type.xml", "r");
291 if (!(out = fopen(filename,"w")))
293 fprintf(stderr, "error in openinf file %s\n", filename);
298 fprintf(out,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
299 fprintf(out,"<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:h=\"http://www.cs.unibo.it/helm/schemas/mattone.rdf#\">\n");
300 fprintf(out,"\t<h:Object rdf:about=\"");
301 fprintf(out,"%s",file_uri);
302 fprintf(out,"\">\n");
304 fprintf(out,"\t</h:Object>\n");
305 fprintf(out,"</rdf:RDF>\n");
310 search(uri,first_child,position)
315 if (first_child == HERE)
317 if (position == INHYP)
318 found = search_bucket(uri,MAINHYP);
319 else if (position == INCONCL)
320 found = search_bucket(uri,MAINCONCL);
321 /* if (found == NOTFOUND)
322 printf( "pos = %d, uri = %s\n", MAINCONCL, uri); */
324 else found = search_bucket(uri,position);
325 /* if (found == NOTFOUND)
326 printf( "pos = %d, uri = %s\n", position, uri); */