/*
* 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 * nfa,
struct state * oldState,
- struct state * newState,
- int all)
+ struct state * newState)
{
assert(oldState != newState);
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
{
{
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 */
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);
}
/*
* 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 * nfa,
struct state * oldState,
- struct state * newState,
- int all)
+ struct state * newState)
{
assert(oldState != newState);
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
{
{
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 */
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);
}
fprintf(f, "\nfinal cleanup:\n");
#endif
cleanup(nfa); /* final tidying */
+#ifdef REG_DEBUG
+ if (verbose)
+ dumpnfa(nfa, f);
+#endif
return analyze(nfa); /* and analysis */
}
s = newstate(nfa);
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())
s = newstate(nfa);
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())
{
#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)
fprintf(f, ", eol [%ld]", (long) nfa->eos[1]);
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);
fflush(f);
static void sortouts(struct nfa *, struct state *);
static int sortouts_cmp(const void *, const void *);
static void moveins(struct nfa *, struct state *, struct state *);
-static void copyins(struct nfa *, struct state *, struct state *, int);
+static void copyins(struct nfa *, struct state *, struct state *);
static void mergeins(struct nfa *, struct state *, struct arc **, int);
static void moveouts(struct nfa *, struct state *, struct state *);
-static void copyouts(struct nfa *, struct state *, struct state *, int);
+static void copyouts(struct nfa *, struct state *, struct state *);
static void cloneouts(struct nfa *, struct state *, struct state *, struct state *, int);
static void delsub(struct nfa *, struct state *, struct state *);
static void deltraverse(struct nfa *, struct state *, struct state *);
#ifdef REG_DEBUG
static void dumpstate(struct state *, FILE *);
static void dumparcs(struct state *, FILE *);
-static int dumprarcs(struct arc *, struct state *, FILE *, int);
static void dumparc(struct arc *, struct state *, FILE *);
static void dumpcnfa(struct cnfa *, FILE *);
static void dumpcstate(int, struct cnfa *, FILE *);
for (s = slist; s != NULL; s = s2)
{
s2 = newstate(nfa);
- copyouts(nfa, s, s2, 1);
+ NOERR();
+ copyouts(nfa, s, s2);
+ NOERR();
for (a = s->ins; a != NULL; a = b)
{
b = a->inchain;
dumpcolors(&g->cmap, f);
if (!NULLCNFA(g->search))
{
- printf("\nsearch:\n");
+ fprintf(f, "\nsearch:\n");
dumpcnfa(&g->search, f);
}
for (i = 1; i < g->nlacons; i++)