summaryrefslogtreecommitdiffstats
path: root/generic/regc_nfa.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2015-10-20 20:21:44 (GMT)
committerdgp <dgp@users.sourceforge.net>2015-10-20 20:21:44 (GMT)
commit1636c5d39afbc31d28a123a92c24eb6bf576b725 (patch)
treea4b1253b0b21a324ac93ecaa8709fcdeca12e2dc /generic/regc_nfa.c
parent33180e74dd94cef71ddc6ed6ea7436bd2736461d (diff)
downloadtcl-1636c5d39afbc31d28a123a92c24eb6bf576b725.zip
tcl-1636c5d39afbc31d28a123a92c24eb6bf576b725.tar.gz
tcl-1636c5d39afbc31d28a123a92c24eb6bf576b725.tar.bz2
Adaptation of most of the re-mopup.patch from Tom Lane @ postgress.
Still should add the new tests.
Diffstat (limited to 'generic/regc_nfa.c')
-rw-r--r--generic/regc_nfa.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/generic/regc_nfa.c b/generic/regc_nfa.c
index 5568bff..6280e5e 100644
--- a/generic/regc_nfa.c
+++ b/generic/regc_nfa.c
@@ -843,15 +843,13 @@ moveins(
/*
- copyins - copy in arcs of a state to another state
- * Either all arcs, or only non-empty ones as determined by all value.
^ static VOID copyins(struct nfa *, struct state *, struct state *, int);
*/
static void
copyins(
struct nfa *nfa,
struct state *oldState,
- struct state *newState,
- int all)
+ struct state *newState)
{
assert(oldState != newState);
@@ -860,9 +858,7 @@ copyins(
struct arc *a;
for (a = oldState->ins; a != NULL; a = a->inchain) {
- if (all || a->type != EMPTY) {
- cparc(nfa, a, a->from, newState);
- }
+ cparc(nfa, a, a->from, newState);
}
} else {
/*
@@ -892,11 +888,6 @@ copyins(
while (oa != NULL && na != NULL) {
struct arc *a = oa;
- if (!all && a->type == EMPTY) {
- oa = oa->inchain;
- continue;
- }
-
switch (sortins_cmp(&oa, &na)) {
case -1:
/* newState does not have anything matching oa */
@@ -920,11 +911,6 @@ copyins(
/* newState does not have anything matching oa */
struct arc *a = oa;
- if (!all && a->type == EMPTY) {
- oa = oa->inchain;
- continue;
- }
-
oa = oa->inchain;
createarc(nfa, a->type, a->co, a->from, newState);
}
@@ -1114,15 +1100,13 @@ moveouts(
/*
- copyouts - copy out arcs of a state to another state
- * Either all arcs, or only non-empty ones as determined by all value.
^ static VOID copyouts(struct nfa *, struct state *, struct state *, int);
*/
static void
copyouts(
struct nfa *nfa,
struct state *oldState,
- struct state *newState,
- int all)
+ struct state *newState)
{
assert(oldState != newState);
@@ -1131,9 +1115,7 @@ copyouts(
struct arc *a;
for (a = oldState->outs; a != NULL; a = a->outchain) {
- if (all || a->type != EMPTY) {
- cparc(nfa, a, newState, a->to);
- }
+ cparc(nfa, a, newState, a->to);
}
} else {
/*
@@ -1163,11 +1145,6 @@ copyouts(
while (oa != NULL && na != NULL) {
struct arc *a = oa;
- if (!all && a->type == EMPTY) {
- oa = oa->outchain;
- continue;
- }
-
switch (sortouts_cmp(&oa, &na)) {
case -1:
/* newState does not have anything matching oa */
@@ -1191,11 +1168,6 @@ copyouts(
/* newState does not have anything matching oa */
struct arc *a = oa;
- if (!all && a->type == EMPTY){
- oa = oa->outchain;
- continue;
- }
-
oa = oa->outchain;
createarc(nfa, a->type, a->co, newState, a->to);
}
@@ -1446,6 +1418,11 @@ optimize(
fprintf(f, "\nfinal cleanup:\n");
}
cleanup(nfa); /* final tidying */
+#ifdef REG_DEBUG
+ if (verbose) {
+ dumpnfa(nfa, f);
+ }
+#endif
return analyze(nfa); /* and analysis */
}
@@ -1570,7 +1547,7 @@ pull(
if (NISERR()) {
return 0;
}
- copyins(nfa, from, s, 1); /* duplicate inarcs */
+ copyins(nfa, from, s); /* duplicate inarcs */
cparc(nfa, con, s, to); /* move constraint arc */
freearc(nfa, con);
if (NISERR()) {
@@ -1749,7 +1726,7 @@ push(
if (NISERR()) {
return 0;
}
- copyouts(nfa, to, s, 1); /* duplicate outarcs */
+ copyouts(nfa, to, s); /* duplicate outarcs */
cparc(nfa, con, from, s); /* move constraint arc */
freearc(nfa, con);
if (NISERR()) {
@@ -2958,6 +2935,8 @@ dumpnfa(
{
#ifdef REG_DEBUG
struct state *s;
+ int nstates = 0;
+ int narcs = 0;
fprintf(f, "pre %d, post %d", nfa->pre->no, nfa->post->no);
if (nfa->bos[0] != COLORLESS) {
@@ -2975,7 +2954,10 @@ dumpnfa(
fprintf(f, "\n");
for (s = nfa->states; s != NULL; s = s->next) {
dumpstate(s, f);
+ nstates++;
+ narcs += s->nouts;
}
+ fprintf(f, "total of %d states, %d arcs\n", nstates, narcs);
if (nfa->parent == NULL) {
dumpcolors(nfa->cm, f);
}