int main(int argc, char *argv[])
{
struct stat buf;
+ char *name;
+ char *poss;
+ char *posd;
/* FILE *debug; */
yylex();
fclose(yyin);
print_all(argv[1]);
+ poss = rindex(argv[1],'/');
+ posd = rindex(argv[1],'.');
+ name = (char *)malloc((posd - poss) * sizeof(char));
+ strncpy(name, poss + 1, posd - poss - 1);
+ name[posd - poss - 1] = '\0';
+ print_name(name,argv[1]);
+ free(name);
return 0;
}
char *tmp;
char *source_uri;
char *source_uri_prefix;
+int waiting_for_name = 0;
void search(char *uri, int first_child, int position, int depth);
%}
uri [^"]+
digits [0-9]+
value [^"]+
+id [a-zA-Z]([-_a-zA-Z])+
/***************************************************************/
/* 4. Rules. */
constructor=0;
position = INTYPE;
first_child = HERE;
- }
+ waiting_for_name = 1;
-"</arity>" { tmp = (char *)malloc(sizeof('a')*128);
+ tmp = (char *)malloc(sizeof('a')*128);
strcpy(source_uri,source_uri_prefix);
sprintf(tmp,"#xpointer(1/%d)", inductive_type);
strcat(source_uri,tmp);
/* fprintf(stderr,"cinque"); */
free(tmp);
+ }
+
+"</arity>" {
print_all(source_uri);
/* print_file(); */
}
constructor++;
position = INTYPE;
first_child = HERE;
- }
+ waiting_for_name = 1;
-"</Constructor>" { tmp = (char *)malloc(sizeof('a')*128);
+ tmp = (char *)malloc(sizeof('a')*128);
strcpy(source_uri,source_uri_prefix);
sprintf(tmp,"#xpointer(1/%d/%d)",inductive_type,constructor);
strcat(source_uri,tmp);
free(tmp);
- print_all(source_uri);
+ }
+
+"</Constructor>" { print_all(source_uri);
/* print_file(); */
}
first_child = AFTER;};
}
+"name=\""{id} {
+ if (waiting_for_name == 1) {
+ waiting_for_name = 0;
+ strsep(&yytext,&sep);
+ tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
+ strcpy(tmp,yytext);
+ print_name(tmp,source_uri);
+ free(tmp);
+ }
+ }
%%
}
}
+void print_name(char *name, char *uri)
+{
+ printf("INSERT INTO objectName VALUES ('%s', '%s');\n",uri,name);
+}
/****************************************************************/
/* 5. Definitions of functions local to the module. */
extern void init_symbol_table();
extern void print_all(char *);
+extern void print_name(char *, char *);
extern int search_bucket(char *, int, int);