eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] Changes to eliot/dic/dic_search.c


From: eliot-dev
Subject: [Eliot-dev] Changes to eliot/dic/dic_search.c
Date: Thu, 05 May 2005 19:45:13 -0400

Index: eliot/dic/dic_search.c
diff -u eliot/dic/dic_search.c:1.10 eliot/dic/dic_search.c:1.11
--- eliot/dic/dic_search.c:1.10 Wed Apr 27 17:35:03 2005
+++ eliot/dic/dic_search.c      Thu May  5 23:45:04 2005
@@ -1,13 +1,14 @@
 /* Eliot                                                                     */
-/* Copyright (C) 1999  antoine.fraboulet                                     */
-/* address@hidden                                                 */
+/* Copyright (C) 1999  Antoine Fraboulet                                     */
 /*                                                                           */
-/* This program is free software; you can redistribute it and/or modify      */
+/* This file is part of Eliot.                                               */
+/*                                                                           */
+/* Eliot 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.                                       */
 /*                                                                           */
-/* This program is distributed in the hope that it will be useful,           */
+/* Elit 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.                              */
@@ -15,8 +16,9 @@
 /* You should have received a copy of the GNU General Public License         */
 /* along with this program; if not, write to the Free Software               */
 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
 /*
- * $Id: dic_search.c,v 1.10 2005/04/27 17:35:03 afrab Exp $
+ * $Id: dic_search.c,v 1.11 2005/05/05 23:45:04 afrab Exp $
  */
 
 /**
@@ -36,9 +38,16 @@
 #include "dic_search.h"
 #include "libdic_a-er.h" /* generated by bison */
 #include "scanner.h"     /* generated by flex  */
-
 #include "automaton.h"
 
+/*
+ * shut down the compiler
+ */
+static int yy_init_globals (yyscan_t yyscanner )
+{
+  yy_init_globals(yyscanner);
+  return 0;
+}
 
 /**
  * Dic_seel_edgeptr
@@ -424,86 +433,34 @@
                      Dawg_edge *edgeptr, 
                      char wordlist[RES_REGE_MAX][DIC_WORD_MAX])
 {
-  int i;
   int next_state;
-  int special_char;
   Dawg_edge *current;
-
   /* if we have a valid word we store it */
-  if (params->automaton->accept[state] && edgeptr->term)
+  if (automaton_get_accept(params->automaton,state) && edgeptr->term)
     {
       if (params->wordlistlen < params->wordlistlenmax)
        {
-#ifdef DEBUG_RE
-         fprintf(stdout,"adding word -%s-\n",params->word);
-#endif 
          strcpy(wordlist[params->wordlistlen++],params->word);
        }
-    }
-
+    }  
   /* we now drive the search by exploring the dictionary */
   current = params->dic->dawg + edgeptr->ptr;
   do {
     /* the current letter is current->chr */
-    next_state = params->automaton->Dtrans[state][current->chr];
+    next_state = 
automaton_get_next_state(params->automaton,state,current->chr);
     /* 1 : the letter appears in the automaton as is */
-    if (params->automaton->marque[next_state])
+    if (next_state)
       {
-#ifdef DEBUG_RE_SEARCH
-       fprintf(stderr,"adding letter %c to partial word -%s-\n",current->chr + 
'a' - 1,params->word);
-#endif
        params->word[params->wordlen] = current->chr + 'a' - 1;
        params->wordlen ++;
        Dic_search_regexp_rec(params,next_state,current,wordlist);
        params->wordlen --;
        params->word[params->wordlen] = '\0';
       }
-
-    /* 2 : we search in user defined list */
-    for(i=0; i < DIC_SEARCH_REGE_LIST; i++)
-      {
-       if (params->charlist->valid[i])
-         {
-           /* symbol code in automaton */
-           special_char = params->charlist->symbl[i]; 
-           /* next possible state using the extra symbol */
-           next_state   = params->automaton->Dtrans[state][special_char]; 
-
-           /* current->chr is in the list AND next state is valid */
-           if (params->charlist->letters[i][current->chr] && 
-               params->automaton->marque[next_state])        
-             {
-#ifdef DEBUG_RE_SEARCH
-               fprintf(stderr,"** special char ");
-               regexp_print_letter(stderr,special_char);
-               fprintf(stderr," resolves to ");
-               regexp_print_letter(stderr,current->chr);
-               fprintf(stderr,"\n");
-#endif
-               params->word[params->wordlen] = current->chr + 'a' - 1;
-               params->wordlen ++;
-               Dic_search_regexp_rec(params,next_state,current,wordlist);
-               params->wordlen --;
-               params->word[params->wordlen] = '\0';
-             }
-         }
-#ifdef DEBUG_RE
-       else /* params->charlist->valid[i] */
-         {
-           special_char = params->charlist->symbl[i]; 
-           next_state   = params->automaton->Dtrans[state][special_char]; 
-           if (params->automaton->marque[next_state] && ! 
params->charlist->valid[i])
-             {
-               fprintf(stderr,"special char ");
-               regexp_print_letter(stderr,special_char);
-               fprintf(stderr," appears in automaton but the list is 
invalid\n");
-             }
-         } 
-#endif
-      }
   } while (!(*current++).last);
 }
 
+
     /** 
      * function prototype for parser generated by bison
      */
@@ -556,7 +513,7 @@
 
   if (value)
     {
-#ifdef DEBUG
+#ifdef DEBUG_FLEX_IS_BROKEN
       fprintf(stderr,"parser error at pos %d - %d : %s\n",
              report.pos1, report.pos2, report.msg);
 #endif      
@@ -564,24 +521,6 @@
       return ;
     }
 
-#ifdef DEBUG_RE
-  fprintf(stderr,"recherche de l'expression %s\n",stringbuf);
-  for(i=0; i < DIC_SEARCH_REGE_LIST; i++)
-    {
-      if (list->valid[i])
-       {
-         int j;
-         fprintf(stderr,"lettres (0x%02x) :",i);
-         for(j=0; j<DIC_LETTERS; j++)
-           if (list->letters[i][j])
-             {
-               regexp_print_letter2(stderr,j);
-             }
-         fprintf(stderr,"\n");
-       }
-    }
-#endif
-
   n = 1;
   p = 1;
   regexp_parcours(root, &p, &n, ptl);
@@ -589,14 +528,9 @@
   ptl[0] = p - 1;
 
   regexp_possuivante(root,PS);
-  regexp_delete_tree(root);
 
-  if ((a = automaton_build(root->PP,ptl,PS)) != NULL)
+  if ((a = automaton_build(root->PP,ptl,PS,list)) != NULL)
     {
-#ifdef DEBUG_RE2
-      automaton_dump(a,"auto");
-#endif 
-
       params.dic            = dic;
       params.automaton      = a;
       params.charlist       = list;
@@ -604,10 +538,11 @@
       params.wordlen        = 0;
       params.wordlistlen    = 0;
       params.wordlistlenmax = RES_REGE_MAX;
-      Dic_search_regexp_rec(&params, a->init, dic->dawg + dic->root, wordlist);
+      Dic_search_regexp_rec(&params, automaton_get_init(a), dic->dawg + 
dic->root, wordlist);
       
       automaton_delete(a);
     }
+  regexp_delete_tree(root);
 }
 
 /****************************************/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]