/[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.9 by ipkiss, Sun Oct 23 14:53:43 2005 UTC revision 1.10 by ipkiss, Fri Nov 4 20:00:06 2005 UTC
# Line 17  Line 17 
17  /* along with this program; if not, write to the Free Software               */  /* along with this program; if not, write to the Free Software               */
18  /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */  /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
19    
 /* $Id$ */  
   
20  #include "config.h"  #include "config.h"
21  #include <stdio.h>  #include <stdio.h>
22  #include <stdlib.h>  #include <stdlib.h>
# Line 34  Line 32 
32    
33  #ifndef PDBG  #ifndef PDBG
34  #ifdef DEBUG_RE2  #ifdef DEBUG_RE2
35  #define PDBG(x) x  #define PDBG(x) x
36  #else  #else
37  #define PDBG(x)  #define PDBG(x)
38  #endif  #endif
39  #endif  #endif
40    
# Line 70  static void print_node(FILE*, NODE *n, i Line 68  static void print_node(FILE*, NODE *n, i
68  #endif  #endif
69    
70  /**  /**
71   * computes position, annulable, PP, DP attributes   * computes position, annulable, PP, DP attributes
72   * @param r   = root   * @param r   = root
73   * @param p   = current leaf position   * @param p   = current leaf position
74   * @param n   = current node number   * @param n   = current node number
# Line 126  void regexp_parcours(NODE* r, int *p, in Line 124  void regexp_parcours(NODE* r, int *p, in
124  }  }
125    
126  /**  /**
127   * computes possuivante   * computes possuivante
128   * @param r   = root   * @param r   = root
129   * @param PS  = next position   * @param PS  = next position
130   */   */
# Line 145  void regexp_possuivante(NODE* r, int PS[ Line 143  void regexp_possuivante(NODE* r, int PS[
143      case NODE_AND:      case NODE_AND:
144        /************************************/        /************************************/
145        /* \forall p \in DP(left)           */        /* \forall p \in DP(left)           */
146        /*     PS[p] = PS[p] \cup PP(right) */        /*     PS[p] = PS[p] \cup PP(right) */
147        /************************************/        /************************************/
148        for(pos=1; pos <= PS[0]; pos++)        for(pos=1; pos <= PS[0]; pos++)
149          {          {
# Line 157  void regexp_possuivante(NODE* r, int PS[ Line 155  void regexp_possuivante(NODE* r, int PS[
155        /************************************/        /************************************/
156        /* == same as START                 */        /* == same as START                 */
157        /* \forall p \in DP(left)           */        /* \forall p \in DP(left)           */
158        /*     PS[p] = PS[p] \cup PP(left)  */        /*     PS[p] = PS[p] \cup PP(left)  */
159        /************************************/        /************************************/
160        for(pos=1; pos <= PS[0]; pos++)        for(pos=1; pos <= PS[0]; pos++)
161          {          {
# Line 168  void regexp_possuivante(NODE* r, int PS[ Line 166  void regexp_possuivante(NODE* r, int PS[
166      case NODE_STAR:      case NODE_STAR:
167        /************************************/        /************************************/
168        /* \forall p \in DP(left)           */        /* \forall p \in DP(left)           */
169        /*     PS[p] = PS[p] \cup PP(left)  */        /*     PS[p] = PS[p] \cup PP(left)  */
170        /************************************/        /************************************/
171        for(pos=1; pos <= PS[0]; pos++)        for(pos=1; pos <= PS[0]; pos++)
172          {          {
# Line 225  void regexp_print_letter(FILE* f, char l Line 223  void regexp_print_letter(FILE* f, char l
223      case RE_CONS_MATCH: fprintf(f,"(:c: [%d])",l); break;      case RE_CONS_MATCH: fprintf(f,"(:c: [%d])",l); break;
224      case RE_USR1_MATCH: fprintf(f,"(:1: [%d])",l); break;      case RE_USR1_MATCH: fprintf(f,"(:1: [%d])",l); break;
225      case RE_USR2_MATCH: fprintf(f,"(:2: [%d])",l); break;      case RE_USR2_MATCH: fprintf(f,"(:2: [%d])",l); break;
226      default:      default:
227        if (l < RE_FINAL_TOK)        if (l < RE_FINAL_TOK)
228          fprintf(f," (%c [%d]) ",l + 'a' - 1, l);          fprintf(f," (%c [%d]) ",l + 'a' - 1, l);
229        else        else
230          fprintf(f," (liste %d)",l - RE_LIST_USER_END);          fprintf(f," (liste %d)",l - RE_LIST_USER_END);
231          break;          break;
# Line 248  void regexp_print_letter2(FILE* f, char Line 246  void regexp_print_letter2(FILE* f, char
246      case RE_CONS_MATCH: fprintf(f,":c:"); break;      case RE_CONS_MATCH: fprintf(f,":c:"); break;
247      case RE_USR1_MATCH: fprintf(f,":1:"); break;      case RE_USR1_MATCH: fprintf(f,":1:"); break;
248      case RE_USR2_MATCH: fprintf(f,":2:"); break;      case RE_USR2_MATCH: fprintf(f,":2:"); break;
249      default:      default:
250        if (l < RE_FINAL_TOK)        if (l < RE_FINAL_TOK)
251          fprintf(f,"%c",l + 'a' - 1);          fprintf(f,"%c",l + 'a' - 1);
252        else        else
253          fprintf(f,"l%d",l - RE_LIST_USER_END);          fprintf(f,"l%d",l - RE_LIST_USER_END);
254          break;          break;
# Line 290  static void print_node(FILE* f, NODE *n, Line 288  static void print_node(FILE* f, NODE *n,
288                n->position,n->annulable,n->PP,n->DP);                n->position,n->annulable,n->PP,n->DP);
289      }      }
290  }  }
291  #endif  #endif
292    
293  /*////////////////////////////////////////////////  /*////////////////////////////////////////////////
294  ////////////////////////////////////////////////*/  ////////////////////////////////////////////////*/
# Line 298  static void print_node(FILE* f, NODE *n, Line 296  static void print_node(FILE* f, NODE *n,
296  #ifdef DEBUG_RE  #ifdef DEBUG_RE
297  static void print_tree_nodes(FILE* f, NODE* n, int detail)  static void print_tree_nodes(FILE* f, NODE* n, int detail)
298  {  {
299    if (n == NULL)    if (n == NULL)
300      return;      return;
301    
302    print_tree_nodes(f,n->fg,detail);    print_tree_nodes(f,n->fg,detail);
303    print_tree_nodes(f,n->fd,detail);    print_tree_nodes(f,n->fd,detail);
# Line 321  static void print_tree_edges(FILE* f, NO Line 319  static void print_tree_edges(FILE* f, NO
319    
320    print_tree_edges(f,n->fg);    print_tree_edges(f,n->fg);
321    print_tree_edges(f,n->fd);    print_tree_edges(f,n->fd);
322      
323    switch (n->type)    switch (n->type)
324      {      {
325      case NODE_OR:      case NODE_OR:
# Line 347  static void print_tree_edges(FILE* f, NO Line 345  static void print_tree_edges(FILE* f, NO
345  void regexp_print_tree(NODE* n, char* name, int detail)  void regexp_print_tree(NODE* n, char* name, int detail)
346  {  {
347    FILE* f;    FILE* f;
348    pid_t   pid;    pid_t   pid;
349      
350    f=fopen(name,"w");    f=fopen(name,"w");
351    fprintf(f,"digraph %s {\n",name);    fprintf(f,"digraph %s {\n",name);
352    print_tree_nodes(f,n,detail);    print_tree_nodes(f,n,detail);

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

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