39#define NISERR() VISERR(nfa->v)
40#define NERR(e) VERR(nfa->v, (e))
302 if (
a->to ==
to &&
a->co ==
co &&
a->type == t)
308 if (
a->from ==
from &&
a->co ==
co &&
a->type == t)
509 if (
a->outchain !=
NULL)
511 assert(
a->outchain->outchainRev ==
a);
520 a->outchainRev =
NULL;
553 if (
a->inchain !=
NULL)
555 assert(
a->inchain->inchainRev ==
a);
564 a->inchainRev =
NULL;
566 newto->ins->inchainRev =
a;
649 for (
i = 1;
i < n - 1;
i++)
664 const struct arc *
aa = *((
const struct arc *
const *)
a);
665 const struct arc *
bb = *((
const struct arc *
const *)
b);
668 if (
aa->from->no <
bb->from->no)
670 if (
aa->from->no >
bb->from->no)
676 if (
aa->type <
bb->type)
678 if (
aa->type >
bb->type)
716 for (
i = 1;
i < n - 1;
i++)
731 const struct arc *
aa = *((
const struct arc *
const *)
a);
732 const struct arc *
bb = *((
const struct arc *
const *)
b);
735 if (
aa->to->no <
bb->to->no)
737 if (
aa->to->no >
bb->to->no)
743 if (
aa->type <
bb->type)
745 if (
aa->type >
bb->type)
758#define BULK_ARC_OP_USE_SORT(nsrcarcs, ndestarcs) \
759 ((nsrcarcs) < 4 ? 0 : ((nsrcarcs) > 32 || (ndestarcs) > 32))
1524static struct state *
1530 if (
s1->nouts == 1 &&
s1->outs->type ==
EMPTY)
1533 if (
s2->nins == 1 &&
s2->ins->type ==
EMPTY)
1542 for (
a =
s1->outs;
a !=
NULL;
a =
a->outchain)
1601 fprintf(f,
"\ninitial cleanup:\n");
1619 fprintf(f,
"\nconstraints:\n");
1626 fprintf(f,
"\nfinal cleanup:\n");
1661 if (
a->type ==
'^' ||
a->type ==
BEHIND)
1733 if (from->
nins == 0)
1744 if (from->
nouts > 1)
1832 if (
a->type ==
'$' ||
a->type ==
AHEAD)
1991#define CA(ct,at) (((ct)<<CHAR_BIT) | (at))
1993 switch (
CA(con->
type,
a->type))
2001 if (con->
co ==
a->co)
2022 if (con->
co ==
a->co)
2028 if (con->
co ==
a->co)
2302static struct state *
2808 if (
a2->to->tmp ==
sto)
3279 bool result =
false;
3319 else if (
a->to == s)
3324 else if (
a->to->tmp !=
NULL)
3440 if (
a->to->tmp !=
NULL)
3450 if (
a->to->tmp !=
NULL)
3483 a->from->tmp =
a->from;
3490 if (
a->from->tmp !=
NULL)
3491 a->from->tmp =
NULL;
3500 if (
a->from->tmp !=
NULL)
3503 a->from->tmp =
NULL;
3531 narcs += s->
nouts + 1;
3617 if (
aa->co <
bb->co)
3619 if (
aa->co >
bb->co)
3621 if (
aa->to <
bb->to)
3623 if (
aa->to >
bb->to)
3671 fprintf(f,
", maxmatchall inf");
3682 fprintf(f,
"total of %d states, %d arcs\n", nstates, narcs);
3703 fprintf(f,
"\tstate chain bad\n");
3705 fprintf(f,
"\tno out arcs\n");
3711 fprintf(f,
"\tlink from %d to %d on %d's in-chain\n",
3712 a->from->no,
a->to->no, s->
no);
3730 while (
a->outchain !=
NULL)
3744 }
while (
a !=
NULL);
3785 fprintf(f,
"%c%d",
a->type, (
int)
a->co);
3793 fprintf(f,
"0x%x/0%lo",
a->type, (
long)
a->co);
3843 fprintf(f,
", maxmatchall inf");
static void cleanup(void)
#define fprintf(file, fmt, msg)
static const FormData_pg_attribute a2
#define qsort(a, b, c, d)
static void colorchain(struct colormap *cm, struct arc *a)
static void uncolorchain(struct colormap *cm, struct arc *a)
static color maxcolor(struct colormap *cm)
static color pseudocolor(struct colormap *cm)
static void rainbow(struct nfa *nfa, struct colormap *cm, int type, color but, struct state *from, struct state *to)
static struct state * emptyreachable(struct nfa *nfa, struct state *s, struct state *lastfound, struct arc **inarcsorig)
static void mergeins(struct nfa *nfa, struct state *s, struct arc **arcarray, int arccount)
static void cleartraverse(struct nfa *nfa, struct state *s)
static void cparc(struct nfa *nfa, struct arc *oa, struct state *from, struct state *to)
static void clonesuccessorstates(struct nfa *nfa, struct state *ssource, struct state *sclone, struct state *spredecessor, struct arc *refarc, char *curdonemap, char *outerdonemap, int nstates)
static int combine(struct nfa *nfa, struct arc *con, struct arc *a)
static void copyouts(struct nfa *nfa, struct state *oldState, struct state *newState)
static struct arc * findarc(struct state *s, int type, color co)
static int sortins_cmp(const void *a, const void *b)
#define BULK_ARC_OP_USE_SORT(nsrcarcs, ndestarcs)
static int findconstraintloop(struct nfa *nfa, struct state *s)
static struct arc * allocarc(struct nfa *nfa)
static void compact(struct nfa *nfa, struct cnfa *cnfa)
static void specialcolors(struct nfa *nfa)
static void dupnfa(struct nfa *nfa, struct state *start, struct state *stop, struct state *from, struct state *to)
static long analyze(struct nfa *nfa)
static void duptraverse(struct nfa *nfa, struct state *s, struct state *stmp)
static void newarc(struct nfa *nfa, int t, color co, struct state *from, struct state *to)
static bool checkmatchall_recurse(struct nfa *nfa, struct state *s, bool **haspaths)
static void freenfa(struct nfa *nfa)
static struct state * single_color_transition(struct state *s1, struct state *s2)
static struct nfa * newnfa(struct vars *v, struct colormap *cm, struct nfa *parent)
static void createarc(struct nfa *nfa, int t, color co, struct state *from, struct state *to)
static int isconstraintarc(struct arc *a)
static void fixempties(struct nfa *nfa, FILE *f)
static void copyins(struct nfa *nfa, struct state *oldState, struct state *newState)
static int push(struct nfa *nfa, struct arc *con, struct state **intermediates)
static void moveouts(struct nfa *nfa, struct state *oldState, struct state *newState)
static int hasconstraintout(struct state *s)
static void freearc(struct nfa *nfa, struct arc *victim)
static void checkmatchall(struct nfa *nfa)
static void sortins(struct nfa *nfa, struct state *s)
static void cloneouts(struct nfa *nfa, struct state *old, struct state *from, struct state *to, int type)
static int carc_cmp(const void *a, const void *b)
static long optimize(struct nfa *nfa, FILE *f)
static struct state * newfstate(struct nfa *nfa, int flag)
static void removecantmatch(struct nfa *nfa)
static void sortouts(struct nfa *nfa, struct state *s)
static void deltraverse(struct nfa *nfa, struct state *leftend, struct state *s)
static void dropstate(struct nfa *nfa, struct state *s)
static void removetraverse(struct nfa *nfa, struct state *s)
static void pushfwd(struct nfa *nfa, FILE *f)
static int hasnonemptyout(struct state *s)
static void pullback(struct nfa *nfa, FILE *f)
static void markcanreach(struct nfa *nfa, struct state *s, struct state *okay, struct state *mark)
static void delsub(struct nfa *nfa, struct state *lp, struct state *rp)
static void moveins(struct nfa *nfa, struct state *oldState, struct state *newState)
static bool check_in_colors_match(struct state *s, color co1, color co2)
static void removeconstraints(struct nfa *nfa, struct state *start, struct state *stop)
static struct state * newstate(struct nfa *nfa)
static int sortouts_cmp(const void *a, const void *b)
static void carcsort(struct carc *first, size_t n)
static int pull(struct nfa *nfa, struct arc *con, struct state **intermediates)
static void changearctarget(struct arc *a, struct state *newto)
static void changearcsource(struct arc *a, struct state *newfrom)
static void freestate(struct nfa *nfa, struct state *s)
static void dumpnfa(struct nfa *nfa, FILE *f)
static void markreachable(struct nfa *nfa, struct state *s, struct state *okay, struct state *mark)
static void fixconstraintloops(struct nfa *nfa, FILE *f)
static bool check_out_colors_match(struct state *s, color co1, color co2)
static void breakconstraintloop(struct nfa *nfa, struct state *sinitial)
static void freecnfa(struct cnfa *cnfa)
#define STACK_TOO_DEEP(re)
#define REG_MAX_COMPILE_SPACE
#define STATEBATCHSIZE(n)
struct arc a[FLEXIBLE_ARRAY_MEMBER]
struct statebatch * lastsb
struct state * freestates
struct state s[FLEXIBLE_ARRAY_MEMBER]