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. */ |
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; |
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 */ |
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); |
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; |
256 |
break; |
break; |
257 |
} |
} |
258 |
} |
} |
|
#endif |
|
259 |
|
|
260 |
/*//////////////////////////////////////////////// |
/*//////////////////////////////////////////////// |
261 |
////////////////////////////////////////////////*/ |
////////////////////////////////////////////////*/ |
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,"*"); |
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 |
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); |