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 |
|
|
20 |
|
<<<<<<< automaton.c |
21 |
|
/* $Id$ */ |
22 |
|
|
23 |
|
/** |
24 |
|
* \file automaton.c |
25 |
|
* \brief (Non)Deterministic Finite Automaton for Regexp |
26 |
|
* \author Antoine Fraboulet |
27 |
|
* \date 2005 |
28 |
|
======= |
29 |
/* |
/* |
30 |
* $Id$ |
* $Id$ |
31 |
|
>>>>>>> 1.9 |
32 |
*/ |
*/ |
33 |
|
|
34 |
#include "config.h" |
#include "config.h" |
47 |
#include "alist.h" |
#include "alist.h" |
48 |
#include "automaton.h" |
#include "automaton.h" |
49 |
|
|
50 |
#ifdef DEBUG_AUTOMATON__ |
#ifdef DEBUG_AUTOMATON |
51 |
#define DMSG(a) a |
#define DMSG(a) a |
52 |
#else |
#else |
53 |
#define DMSG(a) |
#define DMSG(a) |
184 |
{ |
{ |
185 |
int i,l; |
int i,l; |
186 |
FILE* f; |
FILE* f; |
187 |
|
#ifdef HAVE_SYS_WAIT_H |
188 |
pid_t pid; |
pid_t pid; |
189 |
|
#endif |
190 |
|
|
191 |
if (a == NULL) |
if (a == NULL) |
192 |
return ; |
return ; |
193 |
f=fopen(filename,"w"); |
f=fopen(filename,"w"); |
428 |
alist_insert(Ry,z->id); /* Ry = Ry \cup succ(z) */ |
alist_insert(Ry,z->id); /* Ry = Ry \cup succ(z) */ |
429 |
} |
} |
430 |
|
|
431 |
#if 0 |
/* \epsilon transition from start node */ |
432 |
if ((z = y->next[RE_EPSILON]) != NULL) /* \delta (y,z) = \epsilon */ |
if ((z = y->next[RE_EPSILON]) != NULL) /* \delta (y,z) = \epsilon */ |
433 |
{ |
{ |
434 |
r = s_automaton_successor(z->id,letter,nfa, list); |
r = s_automaton_successor(z->id,letter,nfa, list); |
435 |
alist_insert(Ry,r); /* Ry = Ry \cup succ(z) */ |
alist_insert(Ry,r); /* Ry = Ry \cup succ(z) */ |
436 |
alist_delete(r); |
alist_delete(r); |
437 |
} |
} |
|
#endif |
|
438 |
|
|
439 |
if (letter < RE_FINAL_TOK) |
if (letter < RE_FINAL_TOK) |
440 |
{ |
{ |
456 |
} |
} |
457 |
} |
} |
458 |
|
|
459 |
// if (alist_is_empty(Ry)) /* Ry = \empty */ |
#if 0 |
460 |
// return Ry; |
if (alist_is_empty(Ry)) /* Ry = \empty */ |
461 |
|
return Ry; |
462 |
|
#endif |
463 |
|
|
464 |
alist_insert(R,Ry); /* R = R \cup Ry */ |
alist_insert(R,Ry); /* R = R \cup Ry */ |
465 |
alist_delete(Ry); |
alist_delete(Ry); |
669 |
s_automaton_dump(Automaton a, char* filename) |
s_automaton_dump(Automaton a, char* filename) |
670 |
{ |
{ |
671 |
FILE* f; |
FILE* f; |
672 |
|
#ifdef HAVE_SYS_WAIT_H |
673 |
pid_t pid; |
pid_t pid; |
674 |
|
#endif |
675 |
if (a == NULL) |
if (a == NULL) |
676 |
return; |
return; |
677 |
f=fopen(filename,"w"); |
f=fopen(filename,"w"); |