/[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.2.1 by afrab, Sun Oct 23 17:13:56 2005 UTC revision 1.9.2.2 by ipkiss, Sun Oct 23 20:58:19 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  /**  /**
21   *  \file   regexp.c   *  \file   regexp.c
22   *  \brief  Regular Expression fonctions   *  \brief  Regular Expression fonctions
# Line 41  Line 39 
39    
40  #ifndef PDBG  #ifndef PDBG
41  #ifdef DEBUG_RE2  #ifdef DEBUG_RE2
42  #define PDBG(x) x  #define PDBG(x) x
43  #else  #else
44  #define PDBG(x)  #define PDBG(x)
45  #endif  #endif
46  #endif  #endif
47    
# Line 77  static void print_node(FILE*, NODE *n, i Line 75  static void print_node(FILE*, NODE *n, i
75  #endif  #endif
76    
77  /**  /**
78   * computes position, annulable, PP, DP attributes   * computes position, annulable, PP, DP attributes
79   * @param r   = root   * @param r   = root
80   * @param p   = current leaf position   * @param p   = current leaf position
81   * @param n   = current node number   * @param n   = current node number
# Line 133  void regexp_parcours(NODE* r, int *p, in Line 131  void regexp_parcours(NODE* r, int *p, in
131  }  }
132    
133  /**  /**
134   * computes possuivante   * computes possuivante
135   * @param r   = root   * @param r   = root
136   * @param PS  = next position   * @param PS  = next position
137   */   */
# Line 152  void regexp_possuivante(NODE* r, int PS[ Line 150  void regexp_possuivante(NODE* r, int PS[
150      case NODE_AND:      case NODE_AND:
151        /************************************/        /************************************/
152        /* \forall p \in DP(left)           */        /* \forall p \in DP(left)           */
153        /*     PS[p] = PS[p] \cup PP(right) */        /*     PS[p] = PS[p] \cup PP(right) */
154        /************************************/        /************************************/
155        for(pos=1; pos <= PS[0]; pos++)        for(pos=1; pos <= PS[0]; pos++)
156          {          {
# Line 164  void regexp_possuivante(NODE* r, int PS[ Line 162  void regexp_possuivante(NODE* r, int PS[
162        /************************************/        /************************************/
163        /* == same as START                 */        /* == same as START                 */
164        /* \forall p \in DP(left)           */        /* \forall p \in DP(left)           */
165        /*     PS[p] = PS[p] \cup PP(left)  */        /*     PS[p] = PS[p] \cup PP(left)  */
166        /************************************/        /************************************/
167        for(pos=1; pos <= PS[0]; pos++)        for(pos=1; pos <= PS[0]; pos++)
168          {          {
# Line 175  void regexp_possuivante(NODE* r, int PS[ Line 173  void regexp_possuivante(NODE* r, int PS[
173      case NODE_STAR:      case NODE_STAR:
174        /************************************/        /************************************/
175        /* \forall p \in DP(left)           */        /* \forall p \in DP(left)           */
176        /*     PS[p] = PS[p] \cup PP(left)  */        /*     PS[p] = PS[p] \cup PP(left)  */
177        /************************************/        /************************************/
178        for(pos=1; pos <= PS[0]; pos++)        for(pos=1; pos <= PS[0]; pos++)
179          {          {
# Line 232  void regexp_print_letter(FILE* f, char l Line 230  void regexp_print_letter(FILE* f, char l
230      case RE_CONS_MATCH: fprintf(f,"(:c: [%d])",l); break;      case RE_CONS_MATCH: fprintf(f,"(:c: [%d])",l); break;
231      case RE_USR1_MATCH: fprintf(f,"(:1: [%d])",l); break;      case RE_USR1_MATCH: fprintf(f,"(:1: [%d])",l); break;
232      case RE_USR2_MATCH: fprintf(f,"(:2: [%d])",l); break;      case RE_USR2_MATCH: fprintf(f,"(:2: [%d])",l); break;
233      default:      default:
234        if (l < RE_FINAL_TOK)        if (l < RE_FINAL_TOK)
235          fprintf(f," (%c [%d]) ",l + 'a' - 1, l);          fprintf(f," (%c [%d]) ",l + 'a' - 1, l);
236        else        else
237          fprintf(f," (liste %d)",l - RE_LIST_USER_END);          fprintf(f," (liste %d)",l - RE_LIST_USER_END);
238          break;          break;
# Line 255  void regexp_print_letter2(FILE* f, char Line 253  void regexp_print_letter2(FILE* f, char
253      case RE_CONS_MATCH: fprintf(f,":c:"); break;      case RE_CONS_MATCH: fprintf(f,":c:"); break;
254      case RE_USR1_MATCH: fprintf(f,":1:"); break;      case RE_USR1_MATCH: fprintf(f,":1:"); break;
255      case RE_USR2_MATCH: fprintf(f,":2:"); break;      case RE_USR2_MATCH: fprintf(f,":2:"); break;
256      default:      default:
257        if (l < RE_FINAL_TOK)        if (l < RE_FINAL_TOK)
258          fprintf(f,"%c",l + 'a' - 1);          fprintf(f,"%c",l + 'a' - 1);
259        else        else
260          fprintf(f,"l%d",l - RE_LIST_USER_END);          fprintf(f,"l%d",l - RE_LIST_USER_END);
261          break;          break;
# Line 297  static void print_node(FILE* f, NODE *n, Line 295  static void print_node(FILE* f, NODE *n,
295                n->position,n->annulable,n->PP,n->DP);                n->position,n->annulable,n->PP,n->DP);
296      }      }
297  }  }
298  #endif  #endif
299    
300  /*////////////////////////////////////////////////  /*////////////////////////////////////////////////
301  ////////////////////////////////////////////////*/  ////////////////////////////////////////////////*/
# Line 305  static void print_node(FILE* f, NODE *n, Line 303  static void print_node(FILE* f, NODE *n,
303  #ifdef DEBUG_RE  #ifdef DEBUG_RE
304  static void print_tree_nodes(FILE* f, NODE* n, int detail)  static void print_tree_nodes(FILE* f, NODE* n, int detail)
305  {  {
306    if (n == NULL)    if (n == NULL)
307      return;      return;
308    
309    print_tree_nodes(f,n->fg,detail);    print_tree_nodes(f,n->fg,detail);
310    print_tree_nodes(f,n->fd,detail);    print_tree_nodes(f,n->fd,detail);
# Line 328  static void print_tree_edges(FILE* f, NO Line 326  static void print_tree_edges(FILE* f, NO
326    
327    print_tree_edges(f,n->fg);    print_tree_edges(f,n->fg);
328    print_tree_edges(f,n->fd);    print_tree_edges(f,n->fd);
329      
330    switch (n->type)    switch (n->type)
331      {      {
332      case NODE_OR:      case NODE_OR:
# Line 354  static void print_tree_edges(FILE* f, NO Line 352  static void print_tree_edges(FILE* f, NO
352  void regexp_print_tree(NODE* n, char* name, int detail)  void regexp_print_tree(NODE* n, char* name, int detail)
353  {  {
354    FILE* f;    FILE* f;
355    pid_t   pid;    pid_t   pid;
356      
357    f=fopen(name,"w");    f=fopen(name,"w");
358    fprintf(f,"digraph %s {\n",name);    fprintf(f,"digraph %s {\n",name);
359    print_tree_nodes(f,n,detail);    print_tree_nodes(f,n,detail);

Legend:
Removed from v.1.9.2.1  
changed lines
  Added in v.1.9.2.2

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