/[eliot]/eliot/dic/regexp.c
ViewVC logotype

Diff of /eliot/dic/regexp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by afrab, Wed Apr 27 17:35:03 2005 UTC revision 1.8 by afrab, Thu May 5 23:45:04 2005 UTC
# Line 1  Line 1 
1  /* Eliot                                                                     */  /* Eliot                                                                     */
2  /* Copyright (C) 1999  antoine.fraboulet                                     */  /* Copyright (C) 1999  Antoine Fraboulet                                     */
 /* antoine.fraboulet@free.fr                                                 */  
3  /*                                                                           */  /*                                                                           */
4  /* This program is free software; you can redistribute it and/or modify      */  /* This file is part of Eliot.                                               */
5    /*                                                                           */
6    /* Eliot is free software; you can redistribute it and/or modify             */
7  /* it under the terms of the GNU General Public License as published by      */  /* it under the terms of the GNU General Public License as published by      */
8  /* the Free Software Foundation; either version 2 of the License, or         */  /* the Free Software Foundation; either version 2 of the License, or         */
9  /* (at your option) any later version.                                       */  /* (at your option) any later version.                                       */
10  /*                                                                           */  /*                                                                           */
11  /* This program is distributed in the hope that it will be useful,           */  /* Elit is distributed in the hope that it will be useful,                   */
12  /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */  /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
13  /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */  /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
14  /* GNU General Public License for more details.                              */  /* GNU General Public License for more details.                              */
# Line 106  void regexp_parcours(NODE* r, int *p, in Line 107  void regexp_parcours(NODE* r, int *p, in
107        r->PP = (r->fg->annulable) ? (r->fg->PP | r->fd->PP) : r->fg->PP;        r->PP = (r->fg->annulable) ? (r->fg->PP | r->fd->PP) : r->fg->PP;
108        r->DP = (r->fd->annulable) ? (r->fg->DP | r->fd->DP) : r->fd->DP;        r->DP = (r->fd->annulable) ? (r->fg->DP | r->fd->DP) : r->fd->DP;
109        break;        break;
     case NODE_QMARK:  
       r->position = 0;  
       r->annulable = 1;  
       r->PP = r->fg->PP;  
       r->DP = r->fg->DP;  
       break;  
110      case NODE_PLUS:      case NODE_PLUS:
111        r->position = 0;        r->position = 0;
112        r->annulable = 0;        r->annulable = 0;
# Line 158  void regexp_possuivante(NODE* r, int PS[ Line 153  void regexp_possuivante(NODE* r, int PS[
153              PS[pos] |= r->fd->PP;              PS[pos] |= r->fd->PP;
154          }          }
155        break;        break;
     case NODE_QMARK:  
       /************************************************/  
       /* \forall p \in DP(left)                       */  
       /*     PS[p] = PS[p] \cup ( PP(left) \minus p ) */  
       /*                                              */  
       /* TODO : correct  a[bcd]?e                     */  
       /* these expression are not handled correctly   */  
       /************************************************/  
       for(pos=1; pos <= PS[0]; pos++)  
         {  
           if (r->DP & (1 << (pos-1)))  
             PS[pos] |= r->PP;  
         }  
       break;  
156      case NODE_PLUS:      case NODE_PLUS:
157        /************************************/        /************************************/
158        /* == same as START                 */        /* == same as START                 */
# Line 233  void regexp_print_ptl(int ptl[]) Line 214  void regexp_print_ptl(int ptl[])
214  /*////////////////////////////////////////////////  /*////////////////////////////////////////////////
215  ////////////////////////////////////////////////*/  ////////////////////////////////////////////////*/
216    
 #ifdef DEBUG_RE  
217  void regexp_print_letter(FILE* f, char l)  void regexp_print_letter(FILE* f, char l)
218  {  {
219    switch (l)    switch (l)
220      {      {
221      case RE_FINAL_TOK:  fprintf(f,"( #  [%d])",RE_FINAL_TOK);  break;      case RE_EPSILON:    fprintf(f,"( &  [%d])",l); break;
222      case RE_ALL_MATCH:  fprintf(f,"( .  [%d])",RE_ALL_MATCH);  break;      case RE_FINAL_TOK:  fprintf(f,"( #  [%d])",l);  break;
223      case RE_VOWL_MATCH: fprintf(f,"(:v: [%d])",RE_VOWL_MATCH); break;      case RE_ALL_MATCH:  fprintf(f,"( .  [%d])",l);  break;
224      case RE_CONS_MATCH: fprintf(f,"(:c: [%d])",RE_CONS_MATCH); break;      case RE_VOWL_MATCH: fprintf(f,"(:v: [%d])",l); break;
225      case RE_USR1_MATCH: fprintf(f,"(:1: [%d])",RE_USR1_MATCH); break;      case RE_CONS_MATCH: fprintf(f,"(:c: [%d])",l); break;
226      case RE_USR2_MATCH: fprintf(f,"(:2: [%d])",RE_USR2_MATCH); break;      case RE_USR1_MATCH: fprintf(f,"(:1: [%d])",l); break;
227        case RE_USR2_MATCH: fprintf(f,"(:2: [%d])",l); break;
228      default:      default:
229        if (l < RE_FINAL_TOK)        if (l < RE_FINAL_TOK)
230          fprintf(f," (%c [%d]) ",l + 'a' - 1, l);          fprintf(f," (%c [%d]) ",l + 'a' - 1, l);
# Line 252  void regexp_print_letter(FILE* f, char l Line 233  void regexp_print_letter(FILE* f, char l
233          break;          break;
234      }      }
235  }  }
 #endif  
236    
237  /*////////////////////////////////////////////////  /*////////////////////////////////////////////////
238  ////////////////////////////////////////////////*/  ////////////////////////////////////////////////*/
239    
 #ifdef DEBUG_RE  
240  void regexp_print_letter2(FILE* f, char l)  void regexp_print_letter2(FILE* f, char l)
241  {  {
242    switch (l)    switch (l)
243      {      {
244        case RE_EPSILON:    fprintf(f,"&"); break;
245      case RE_FINAL_TOK:  fprintf(f,"#");  break;      case RE_FINAL_TOK:  fprintf(f,"#");  break;
246      case RE_ALL_MATCH:  fprintf(f,".");  break;      case RE_ALL_MATCH:  fprintf(f,".");  break;
247      case RE_VOWL_MATCH: fprintf(f,":v:"); break;      case RE_VOWL_MATCH: fprintf(f,":v:"); break;
# Line 276  void regexp_print_letter2(FILE* f, char Line 256  void regexp_print_letter2(FILE* f, char
256          break;          break;
257      }      }
258  }  }
 #endif  
259    
260  /*////////////////////////////////////////////////  /*////////////////////////////////////////////////
261  ////////////////////////////////////////////////*/  ////////////////////////////////////////////////*/
# Line 298  static void print_node(FILE* f, NODE *n, Line 277  static void print_node(FILE* f, NODE *n,
277      case NODE_AND:      case NODE_AND:
278        fprintf(f,"AND");        fprintf(f,"AND");
279        break;        break;
     case NODE_QMARK:  
       fprintf(f,"?");  
       break;  
280      case NODE_PLUS:      case NODE_PLUS:
281        fprintf(f,"*");        fprintf(f,"+");
282        break;        break;
283      case NODE_STAR:      case NODE_STAR:
284        fprintf(f,"*");        fprintf(f,"*");
# Line 310  static void print_node(FILE* f, NODE *n, Line 286  static void print_node(FILE* f, NODE *n,
286      }      }
287    if (detail == 2)    if (detail == 2)
288      {      {
289        fprintf(f,"\\n annulable=%d\\n PP=0x%08x\\n DP=0x%08x",        fprintf(f,"\\n pos=%d\\n annul=%d\\n PP=0x%04x\\n DP=0x%04x",
290                n->annulable,n->PP,n->DP);                n->position,n->annulable,n->PP,n->DP);
291      }      }
292  }  }
293  #endif  #endif
# Line 356  static void print_tree_edges(FILE* f, NO Line 332  static void print_tree_edges(FILE* f, NO
332        fprintf(f,"%d -> %d;",n->numero,n->fg->numero);        fprintf(f,"%d -> %d;",n->numero,n->fg->numero);
333        fprintf(f,"%d -> %d;",n->numero,n->fd->numero);        fprintf(f,"%d -> %d;",n->numero,n->fd->numero);
334        break;        break;
     case NODE_QMARK:  
335      case NODE_PLUS:      case NODE_PLUS:
336      case NODE_STAR:      case NODE_STAR:
337        fprintf(f,"%d -> %d;",n->numero,n->fg->numero);        fprintf(f,"%d -> %d;",n->numero,n->fg->numero);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26