/******************************************************************/ /* Copyright (C) 2000, HELM Team */ /* */ /* This file is part of HELM, an Hypertextual, Electronic */ /* Library of Mathematics, developed at the Computer Science */ /* Department, University of Bologna, Italy. */ /* */ /* HELM is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation; either version */ /* 2 of the License, or (at your option) any later version. */ /* */ /* HELM is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public */ /* License along with HELM; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */ /* MA 02111-1307, USA. */ /* */ /* For details, see the HELM World-Wide-Web page, */ /* http://cs.unibo.it/helm/. */ /******************************************************************/ /***************************************************************/ /* META_LEXAN */ /* Automatic Metadata Extractor */ /* First draft 11/12/2001, by Andrea Asperti */ /***************************************************************/ /***************************************************************/ /* 1. Inclusion of header files. */ /***************************************************************/ %{ #include #include #include "sthandler.h" %} /***************************************************************/ /* 2. Constants and Variables Definitions */ /***************************************************************/ %{ #define NOWHERE 0 #define CONST 1 #define MUTIND 2 #define MUTCONSTRUCT 3 #define INBODY 0 #define MAINHYP 1 #define INHYP 2 #define INCONCL 3 #define MAINCONCL 4 #define INTYPE 5 #define NOTFOUND 6 #define BEFORE 0 #define HERE 1 #define AFTER 2 int where = NOWHERE; int found = NOTFOUND; int position = INBODY; int first_child = BEFORE; int no_open_source =0; int tmp_n; char sep = '"'; char *xpointer = "#xpointer(1/"; char *uri; char *tmp; %} /***************************************************************/ /* 3. Regular definitions. */ /***************************************************************/ uri [^"]+ digits [0-9]+ /***************************************************************/ /* 4. Rules. */ /***************************************************************/ %% "" { position = INTYPE; first_child = BEFORE; } "" { if (position == INHYP) { no_open_source--; /* printf("source %d\n", no_open_source); */ if (no_open_source == 0) { position = INTYPE; first_child = BEFORE; }; }; } "" { position = INBODY; } .|\n { } "\n\n"); printf("\n"); printf("\n"); print_all(); printf("\n"); printf("\n"); } search(uri,first_child,position) 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); */ } int yywrap() { return 1; }